[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: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
2 changed files with 18 additions and 19 deletions

View File

@ -1,6 +1,7 @@
<?php
// {{{ License
// 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
@ -15,6 +16,7 @@
//
// 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/>.
// }}}
/**
@ -47,11 +49,8 @@ class RouteLoader extends Loader
* and $type must not be null
*
* @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();
@ -70,7 +69,7 @@ class RouteLoader extends Loader
*
* @param string $id Route unique id, used to generate urls, for instance
* @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 $options Possible keys are ['condition', 'defaults', 'format',
* 'fragment', 'http-methods', 'locale', 'methods', 'schemes']
@ -118,12 +117,9 @@ class RouteLoader extends Loader
* Passed the arguments from the `RoutingConfigurator::import` call from
* `config/routes.php`
*
* @param mixed $resource Unused
* @param null|string $type
*
* @return bool
* @param mixed $resource
*/
public function supports($resource, string $type = null)
public function supports($resource, ?string $type = null): bool
{
return 'GNUsocial' === $type;
}

View File

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