diff --git a/UPGRADE-5.0.md b/UPGRADE-5.0.md index 7c534c45d065b..89c11993da5a3 100644 --- a/UPGRADE-5.0.md +++ b/UPGRADE-5.0.md @@ -251,6 +251,7 @@ FrameworkBundle * Removed the "Psr\SimpleCache\CacheInterface" / "cache.app.simple" service, use "Symfony\Contracts\Cache\CacheInterface" / "cache.app" instead. * Removed support for `templating` engine in `TemplateController`, use Twig instead * Removed `ResolveControllerNameSubscriber`. + * Removed `routing.loader.service`. HttpClient ---------- @@ -368,6 +369,7 @@ Routing * `Serializable` implementing methods for `Route` and `CompiledRoute` are final. Instead of overwriting them, use `__serialize` and `__unserialize` as extension points which are forward compatible with the new serialization methods in PHP 7.4. + * Removed `ServiceRouterLoader` and `ObjectRouteLoader`. Security -------- diff --git a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md index 09f0fbbf72157..ab8f66171c1cd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md @@ -17,6 +17,7 @@ CHANGELOG * Removed cache-related compiler passes and `RequestDataCollector` * Removed the `translator.selector` and `session.save_listener` services * Removed `SecurityUserValueResolver`, use `UserValueResolver` instead + * Removed `routing.loader.service`. 4.4.0 ----- diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.xml index 75a4873c8359e..aca173f4d6078 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.xml @@ -40,11 +40,6 @@ - - - The "%service_id%" service is deprecated since Symfony 4.4, use "routing.loader.container" instead. - - diff --git a/src/Symfony/Component/Routing/CHANGELOG.md b/src/Symfony/Component/Routing/CHANGELOG.md index 4ce18882e2fb1..bdeb9882cf4d8 100644 --- a/src/Symfony/Component/Routing/CHANGELOG.md +++ b/src/Symfony/Component/Routing/CHANGELOG.md @@ -8,6 +8,7 @@ CHANGELOG * removed `generator_base_class`, `generator_cache_class`, `matcher_base_class` and `matcher_cache_class` router options * `Serializable` implementing methods for `Route` and `CompiledRoute` are final * removed referencing service route loaders with a single colon + * Removed `ServiceRouterLoader` and `ObjectRouteLoader`. 4.4.0 ----- diff --git a/src/Symfony/Component/Routing/Loader/DependencyInjection/ServiceRouterLoader.php b/src/Symfony/Component/Routing/Loader/DependencyInjection/ServiceRouterLoader.php deleted file mode 100644 index a04a19c3c3540..0000000000000 --- a/src/Symfony/Component/Routing/Loader/DependencyInjection/ServiceRouterLoader.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Loader\DependencyInjection; - -use Psr\Container\ContainerInterface; -use Symfony\Component\Routing\Loader\ContainerLoader; -use Symfony\Component\Routing\Loader\ObjectRouteLoader; - -@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.4, use "%s" instead.', ServiceRouterLoader::class, ContainerLoader::class), E_USER_DEPRECATED); - -/** - * A route loader that executes a service to load the routes. - * - * @author Ryan Weaver - * - * @deprecated since Symfony 4.4, use Symfony\Component\Routing\Loader\ContainerLoader instead. - */ -class ServiceRouterLoader extends ObjectRouteLoader -{ - /** - * @var ContainerInterface - */ - private $container; - - public function __construct(ContainerInterface $container) - { - $this->container = $container; - } - - protected function getServiceObject($id) - { - return $this->container->get($id); - } -} diff --git a/src/Symfony/Component/Routing/Loader/ObjectRouteLoader.php b/src/Symfony/Component/Routing/Loader/ObjectRouteLoader.php deleted file mode 100644 index e9debbf48ff7f..0000000000000 --- a/src/Symfony/Component/Routing/Loader/ObjectRouteLoader.php +++ /dev/null @@ -1,76 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Loader; - -use Symfony\Component\Routing\RouteCollection; - -@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.4, use "%s" instead.', ObjectRouteLoader::class, ObjectLoader::class), E_USER_DEPRECATED); - -/** - * A route loader that calls a method on an object to load the routes. - * - * @author Ryan Weaver - * - * @deprecated since Symfony 4.4, use ObjectLoader instead. - */ -abstract class ObjectRouteLoader extends ObjectLoader -{ - /** - * Returns the object that the method will be called on to load routes. - * - * For example, if your application uses a service container, - * the $id may be a service id. - * - * @param string $id - * - * @return object - */ - abstract protected function getServiceObject($id); - - /** - * Calls the service that will load the routes. - * - * @param string $resource Some value that will resolve to a callable - * @param string|null $type The resource type - * - * @return RouteCollection - */ - public function load($resource, string $type = null) - { - if (!preg_match('/^[^\:]+(?:::?(?:[^\:]+))?$/', $resource)) { - throw new \InvalidArgumentException(sprintf('Invalid resource "%s" passed to the "service" route loader: use the format "service::method" or "service" if your service has an "__invoke" method.', $resource)); - } - - if (1 === substr_count($resource, ':')) { - $resource = str_replace(':', '::', $resource); - @trigger_error(sprintf('Referencing service route loaders with a single colon is deprecated since Symfony 4.1. Use %s instead.', $resource), E_USER_DEPRECATED); - } - - return parent::load($resource, $type); - } - - /** - * {@inheritdoc} - */ - public function supports($resource, string $type = null) - { - return 'service' === $type; - } - - /** - * {@inheritdoc} - */ - protected function getObject(string $id) - { - return $this->getServiceObject($id); - } -} diff --git a/src/Symfony/Component/Routing/Tests/Loader/DependencyInjection/ServiceRouterLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/DependencyInjection/ServiceRouterLoaderTest.php deleted file mode 100644 index 497ce2f3b3658..0000000000000 --- a/src/Symfony/Component/Routing/Tests/Loader/DependencyInjection/ServiceRouterLoaderTest.php +++ /dev/null @@ -1,29 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Loader; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\DependencyInjection\Container; -use Symfony\Component\Routing\Loader\DependencyInjection\ServiceRouterLoader; - -class ServiceRouterLoaderTest extends TestCase -{ - /** - * @group legacy - * @expectedDeprecation The "Symfony\Component\Routing\Loader\DependencyInjection\ServiceRouterLoader" class is deprecated since Symfony 4.4, use "Symfony\Component\Routing\Loader\ContainerLoader" instead. - * @expectedDeprecation The "Symfony\Component\Routing\Loader\ObjectRouteLoader" class is deprecated since Symfony 4.4, use "Symfony\Component\Routing\Loader\ObjectLoader" instead. - */ - public function testDeprecationWarning() - { - new ServiceRouterLoader(new Container()); - } -} diff --git a/src/Symfony/Component/Routing/Tests/Loader/ObjectRouteLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/ObjectRouteLoaderTest.php deleted file mode 100644 index 2c6e26a4de7f9..0000000000000 --- a/src/Symfony/Component/Routing/Tests/Loader/ObjectRouteLoaderTest.php +++ /dev/null @@ -1,119 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Routing\Tests\Loader; - -use PHPUnit\Framework\TestCase; -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Routing\Tests\Fixtures\TestObjectRouteLoader; - -/** - * @group legacy - */ -class ObjectRouteLoaderTest extends TestCase -{ - public function testLoadCallsServiceAndReturnsCollection() - { - $loader = new TestObjectRouteLoader(); - - // create a basic collection that will be returned - $collection = new RouteCollection(); - $collection->add('foo', new Route('/foo')); - - $loader->loaderMap = [ - 'my_route_provider_service' => new TestObjectRouteLoaderRouteService($collection), - ]; - - $actualRoutes = $loader->load( - 'my_route_provider_service::loadRoutes', - 'service' - ); - - $this->assertSame($collection, $actualRoutes); - // the service file should be listed as a resource - $this->assertNotEmpty($actualRoutes->getResources()); - } - - /** - * @expectedException \InvalidArgumentException - * @dataProvider getBadResourceStrings - */ - public function testExceptionWithoutSyntax(string $resourceString): void - { - $loader = new TestObjectRouteLoader(); - $loader->load($resourceString); - } - - public function getBadResourceStrings() - { - return [ - ['Foo:Bar:baz'], - ['Foo::Bar::baz'], - ['Foo:'], - ['Foo::'], - [':Foo'], - ['::Foo'], - ]; - } - - /** - * @expectedException \LogicException - */ - public function testExceptionOnNoObjectReturned() - { - $loader = new TestObjectRouteLoader(); - $loader->loaderMap = ['my_service' => 'NOT_AN_OBJECT']; - $loader->load('my_service::method'); - } - - /** - * @expectedException \BadMethodCallException - */ - public function testExceptionOnBadMethod() - { - $loader = new TestObjectRouteLoader(); - $loader->loaderMap = ['my_service' => new \stdClass()]; - $loader->load('my_service::method'); - } - - /** - * @expectedException \LogicException - */ - public function testExceptionOnMethodNotReturningCollection() - { - $service = $this->getMockBuilder('stdClass') - ->setMethods(['loadRoutes']) - ->getMock(); - $service->expects($this->once()) - ->method('loadRoutes') - ->willReturn('NOT_A_COLLECTION'); - - $loader = new TestObjectRouteLoader(); - $loader->loaderMap = ['my_service' => $service]; - $loader->load('my_service::loadRoutes'); - } -} - -class TestObjectRouteLoaderRouteService -{ - private $collection; - - public function __construct($collection) - { - $this->collection = $collection; - } - - public function loadRoutes() - { - return $this->collection; - } -}