[CORE][Symfony] Fixed deprecation resultant from Symfony 5.1 upgrade

User Deprecated: Since symfony/framework-bundle 5.1: Using type
"Symfony\Component\Routing\RouteCollectionBuilder" for argument 1 of
method "App\Kernel:configureRoutes()" is deprecated, use
"Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator"
instead.
This commit is contained in:
Hugo Sales 2020-06-23 12:43:19 +00:00 committed by Hugo Sales
parent 7a52c1d823
commit bc6ead4ab1
Signed by untrusted user: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
2 changed files with 18 additions and 19 deletions

View File

@ -1,6 +1,7 @@
<?php <?php
// {{{ License // {{{ License
// This file is part of GNU social - https://www.gnu.org/software/social // This file is part of GNU social - https://www.gnu.org/software/social
// //
// GNU social is free software: you can redistribute it and/or modify // GNU social is free software: you can redistribute it and/or modify
@ -15,6 +16,7 @@
// //
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with GNU social. If not, see <http://www.gnu.org/licenses/>. // along with GNU social. If not, see <http://www.gnu.org/licenses/>.
// }}} // }}}
/** /**
@ -46,12 +48,9 @@ class RouteLoader extends Loader
* Must conform to symfony's interface, but the $resource is unused * Must conform to symfony's interface, but the $resource is unused
* and $type must not be null * and $type must not be null
* *
* @param mixed $resource * @param mixed $resource
* @param null|string $type
*
* @return RouteCollection
*/ */
public function load($resource, string $type = null): RouteCollection public function load($resource, ?string $type = null): RouteCollection
{ {
$this->rc = new RouteCollection(); $this->rc = new RouteCollection();
@ -70,7 +69,7 @@ class RouteLoader extends Loader
* *
* @param string $id Route unique id, used to generate urls, for instance * @param string $id Route unique id, used to generate urls, for instance
* @param string $uri_path Path, possibly with {param}s * @param string $uri_path Path, possibly with {param}s
* @param mixed $target Some kind of callable, typically [object, method] * @param mixed $target Some kind of callable, typically class with `__invoke` or [object, method]
* @param null|array $param_reqs Array of {param} => regex * @param null|array $param_reqs Array of {param} => regex
* @param null|array $options Possible keys are ['condition', 'defaults', 'format', * @param null|array $options Possible keys are ['condition', 'defaults', 'format',
* 'fragment', 'http-methods', 'locale', 'methods', 'schemes'] * 'fragment', 'http-methods', 'locale', 'methods', 'schemes']
@ -80,7 +79,7 @@ class RouteLoader extends Loader
{ {
$this->rc->add($id, $this->rc->add($id,
new Route( new Route(
// path -- URI path // path -- URI path
$uri_path, $uri_path,
// defaults = [] -- param default values, // defaults = [] -- param default values,
// and special configuration options // and special configuration options
@ -118,12 +117,9 @@ class RouteLoader extends Loader
* Passed the arguments from the `RoutingConfigurator::import` call from * Passed the arguments from the `RoutingConfigurator::import` call from
* `config/routes.php` * `config/routes.php`
* *
* @param mixed $resource Unused * @param mixed $resource
* @param null|string $type
*
* @return bool
*/ */
public function supports($resource, string $type = null) public function supports($resource, ?string $type = null): bool
{ {
return 'GNUsocial' === $type; return 'GNUsocial' === $type;
} }

View File

@ -31,14 +31,13 @@
namespace App; namespace App;
use App\DependencyInjection\Compiler\SchemaDefPass; use App\DependencyInjection\Compiler\SchemaDefPass;
use const PHP_VERSION_ID; use const PHP_VERSION_ID;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\Config\Loader\LoaderInterface; use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\Config\Resource\FileResource; use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel as BaseKernel; use Symfony\Component\HttpKernel\Kernel as BaseKernel;
use Symfony\Component\Routing\RouteCollectionBuilder; use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
class Kernel extends BaseKernel class Kernel extends BaseKernel
{ {
@ -103,13 +102,17 @@ class Kernel extends BaseKernel
$loader->load($confDir . '/{services}_' . $this->environment . self::CONFIG_EXTS, 'glob'); $loader->load($confDir . '/{services}_' . $this->environment . self::CONFIG_EXTS, 'glob');
} }
protected function configureRoutes(RouteCollectionBuilder $routes): void protected function configureRoutes(RoutingConfigurator $routes): void
{ {
$confDir = $this->getProjectDir() . '/config'; $config = \dirname(__DIR__) . '/config';
$routes->import($config . '/{routes}/' . $this->environment . '/*.yaml');
$routes->import($config . '/{routes}/*.yaml');
$routes->import($confDir . '/{routes}/' . $this->environment . '/*' . self::CONFIG_EXTS, '/', 'glob'); if (is_file($config . '/routes.yaml')) {
$routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS, '/', 'glob'); $routes->import($config . '/{routes}.yaml');
$routes->import($confDir . '/{routes}' . self::CONFIG_EXTS, '/', 'glob'); } elseif (is_file($path = $config . '/routes.php')) {
(require $path)($routes->withPath($path), $this);
}
} }
protected function build(ContainerBuilder $container): void protected function build(ContainerBuilder $container): void