diff --git a/UPGRADE-5.0.md b/UPGRADE-5.0.md index a32dabf10428b..58a08d5d69358 100644 --- a/UPGRADE-5.0.md +++ b/UPGRADE-5.0.md @@ -91,6 +91,7 @@ FrameworkBundle * Removed `Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser`. * Warming up a router in `RouterCacheWarmer` that does not implement the `WarmableInterface` is not supported anymore. * The `RequestDataCollector` class has been removed. Use the `Symfony\Component\HttpKernel\DataCollector\RequestDataCollector` class instead. + * Removed `Symfony\Bundle\FrameworkBundle\Controller\Controller`. Use `Symfony\Bundle\FrameworkBundle\Controller\AbstractController` instead. HttpFoundation -------------- diff --git a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md index 79f3c475676fc..6b4af469bd8f6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md @@ -8,6 +8,7 @@ CHANGELOG * Allowed configuring PDO-based cache pools via a new `cache.adapter.pdo` abstract service * Deprecated auto-injection of the container in AbstractController instances, register them as service subscribers instead * Deprecated processing of services tagged `security.expression_language_provider` in favor of a new `AddExpressionLanguageProvidersPass` in SecurityBundle. + * Deprecated the `Symfony\Bundle\FrameworkBundle\Controller\Controller` class in favor of `Symfony\Bundle\FrameworkBundle\Controller\AbstractController`. * Enabled autoconfiguration for `Psr\Log\LoggerAwareInterface` 4.1.0 diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php b/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php index 51ac58b9fae83..9ab6f9eb4980d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php @@ -14,11 +14,15 @@ use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerAwareTrait; +@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.2, use %s instead.', Controller::class, AbstractController::class), E_USER_DEPRECATED); + /** * Controller is a simple implementation of a Controller. * * It provides methods to common features needed in controllers. * + * @deprecated since Symfony 4.2, use {@see AbstractController} instead. + * * @author Fabien Potencier */ abstract class Controller implements ContainerAwareInterface diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index be33ae7aba0b8..f7915ad983efe 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -18,7 +18,6 @@ use Symfony\Bridge\Monolog\Processor\ProcessorInterface; use Symfony\Bridge\Twig\Extension\CsrfExtension; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Bundle\FrameworkBundle\Routing\AnnotatedRouteControllerLoader; use Symfony\Bundle\FullStack; use Symfony\Component\Cache\Adapter\AbstractAdapter; @@ -296,7 +295,6 @@ public function load(array $configs, ContainerBuilder $container) // Added explicitly so that we don't rely on the class map being dumped to make it work 'Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController', - 'Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller', )); $container->registerForAutoconfiguration(Command::class) @@ -313,7 +311,7 @@ public function load(array $configs, ContainerBuilder $container) ->addTag('controller.argument_value_resolver'); $container->registerForAutoconfiguration(AbstractController::class) ->addTag('controller.service_arguments'); - $container->registerForAutoconfiguration(Controller::class) + $container->registerForAutoconfiguration('Symfony\Bundle\FrameworkBundle\Controller\Controller') ->addTag('controller.service_arguments'); $container->registerForAutoconfiguration(DataCollectorInterface::class) ->addTag('data_collector'); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php index 452845cea8e34..feff96bc44448 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php @@ -11,8 +11,9 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Controller; -use Symfony\Bundle\FrameworkBundle\Controller\Controller; - +/** + * @group legacy + */ class ControllerTest extends ControllerTraitTest { protected function createController() @@ -20,8 +21,3 @@ protected function createController() return new TestController(); } } - -class TestController extends Controller -{ - use TestControllerTrait; -} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TestController.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TestController.php new file mode 100644 index 0000000000000..595dfd8d32c92 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TestController.php @@ -0,0 +1,10 @@ +