From 453efdfe1eb201142f464ff493317f8c688e913d Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Wed, 14 Nov 2018 14:05:48 +0100 Subject: [PATCH] Undeprecate the single-colon notation for controllers This notation is the only way to support controllers as services in the 3.4 LTS version. This deprecation has only a very small benefit for the Symfony codebase (the amount of code involved is very small), but has a huge cost for the community which cannot avoid this deprecation without dropping support for the LTS or making crazy logic to switch routing files (as they cannot switch things inline in YAML or XML files). This deprecation will be delayed until a future 5.x version, when the current LTS will be 4.4 (which supports the new notation). --- UPGRADE-5.0.md | 12 +----------- src/Symfony/Component/HttpKernel/CHANGELOG.md | 2 +- .../Controller/ContainerControllerResolver.php | 2 +- .../Controller/ContainerControllerResolverTest.php | 4 ---- 4 files changed, 3 insertions(+), 17 deletions(-) diff --git a/UPGRADE-5.0.md b/UPGRADE-5.0.md index 61b7237b44923..f87e5dc62632d 100644 --- a/UPGRADE-5.0.md +++ b/UPGRADE-5.0.md @@ -30,7 +30,7 @@ EventDispatcher FrameworkBundle --------------- - * Removed support for `bundle:controller:action` and `service:action` syntaxes to reference controllers. Use `serviceOrFqcn::method` + * Removed support for `bundle:controller:action` syntax to reference controllers. Use `serviceOrFqcn::method` instead where `serviceOrFqcn` is either the service ID when using controllers as services or the FQCN of the controller. Before: @@ -40,11 +40,6 @@ FrameworkBundle path: / defaults: _controller: FrameworkBundle:Redirect:redirect - - service_controller: - path: / - defaults: - _controller: app.my_controller:myAction ``` After: @@ -54,11 +49,6 @@ FrameworkBundle path: / defaults: _controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController::redirectAction - - service_controller: - path: / - defaults: - _controller: app.my_controller::myAction ``` * Removed `Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser`. diff --git a/src/Symfony/Component/HttpKernel/CHANGELOG.md b/src/Symfony/Component/HttpKernel/CHANGELOG.md index c98d2235e333d..6393b9f78c488 100644 --- a/src/Symfony/Component/HttpKernel/CHANGELOG.md +++ b/src/Symfony/Component/HttpKernel/CHANGELOG.md @@ -6,7 +6,7 @@ CHANGELOG * added orphaned events support to `EventDataCollector` * `ExceptionListener` now logs exceptions at priority `0` (previously logged at `-128`) - * Deprecated `service:action` syntax with a single colon to reference controllers. Use `service::method` instead. + * Added support for using `service::method` to reference controllers, making it consistent with other cases. It is recommended over the `service:action` syntax with a single colon, which will be deprecated in the future. * Added the ability to profile individual argument value resolvers via the `Symfony\Component\HttpKernel\Controller\ArgumentResolver\TraceableValueResolver` diff --git a/src/Symfony/Component/HttpKernel/Controller/ContainerControllerResolver.php b/src/Symfony/Component/HttpKernel/Controller/ContainerControllerResolver.php index ed515d247c398..4f80921cf58f4 100644 --- a/src/Symfony/Component/HttpKernel/Controller/ContainerControllerResolver.php +++ b/src/Symfony/Component/HttpKernel/Controller/ContainerControllerResolver.php @@ -36,7 +36,7 @@ protected function createController($controller) { if (1 === substr_count($controller, ':')) { $controller = str_replace(':', '::', $controller); - @trigger_error(sprintf('Referencing controllers with a single colon is deprecated since Symfony 4.1. Use %s instead.', $controller), E_USER_DEPRECATED); + // TODO deprecate this in 5.1 } return parent::createController($controller); diff --git a/src/Symfony/Component/HttpKernel/Tests/Controller/ContainerControllerResolverTest.php b/src/Symfony/Component/HttpKernel/Tests/Controller/ContainerControllerResolverTest.php index 57414d001281f..1a144eee49c4b 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Controller/ContainerControllerResolverTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Controller/ContainerControllerResolverTest.php @@ -19,10 +19,6 @@ class ContainerControllerResolverTest extends ControllerResolverTest { - /** - * @group legacy - * @expectedDeprecation Referencing controllers with a single colon is deprecated since Symfony 4.1. Use foo::action instead. - */ public function testGetControllerServiceWithSingleColon() { $service = new ControllerTestService('foo');