From 744bf0e7ac3ecf240d0bf055cc58f881bb0b3ec0 Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Sun, 9 Sep 2018 19:07:56 +0200 Subject: [PATCH] [FrameworkBundle] Deprecate ContainerAwareCommand --- UPGRADE-4.2.md | 2 ++ UPGRADE-5.0.md | 2 ++ src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md | 5 +++-- .../Bundle/FrameworkBundle/Command/ContainerAwareCommand.php | 4 ++++ .../Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php | 4 ++++ 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/UPGRADE-4.2.md b/UPGRADE-4.2.md index 3b1ecc251df78..67481540bd232 100644 --- a/UPGRADE-4.2.md +++ b/UPGRADE-4.2.md @@ -102,6 +102,8 @@ FrameworkBundle serializer: id: your_messenger_service_id ``` + * The `ContainerAwareCommand` class has been deprecated, use `Symfony\Component\Console\Command\Command` + with dependency injection instead. Messenger --------- diff --git a/UPGRADE-5.0.md b/UPGRADE-5.0.md index 23be0dcf556ce..caea8ca9c1d85 100644 --- a/UPGRADE-5.0.md +++ b/UPGRADE-5.0.md @@ -93,6 +93,8 @@ FrameworkBundle * 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. * Added support for the SameSite attribute for session cookies. It is highly recommended to set this setting (`framework.session.cookie_samesite`) to `lax` for increased security against CSRF attacks. + * The `ContainerAwareCommand` class has been removed, use `Symfony\Component\Console\Command\Command` + with dependency injection instead. HttpFoundation -------------- diff --git a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md index 74f9b24311b23..65338f1be7292 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md @@ -11,8 +11,9 @@ CHANGELOG * Deprecated the `Symfony\Bundle\FrameworkBundle\Controller\Controller` class in favor of `Symfony\Bundle\FrameworkBundle\Controller\AbstractController`. * Enabled autoconfiguration for `Psr\Log\LoggerAwareInterface` * Added new "auto" mode for `framework.session.cookie_secure` to turn it on when HTTPS is used - * Removed the `framework.messenger.encoder` and `framework.messenger.decoder` options. Use the `framework.messenger.serializer.id` option to replace the Messenger serializer. - + * Removed the `framework.messenger.encoder` and `framework.messenger.decoder` options. Use the `framework.messenger.serializer.id` option to replace the Messenger serializer. + * Deprecated the `ContainerAwareCommand` class in favor of `Symfony\Component\Console\Command\Command` + 4.1.0 ----- diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ContainerAwareCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ContainerAwareCommand.php index 2c84e7f72f395..7b01a55ef8af5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ContainerAwareCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ContainerAwareCommand.php @@ -15,10 +15,14 @@ use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerInterface; +@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.2, use "%s" with dependency injection instead.', ContainerAwareCommand::class, Command::class), E_USER_DEPRECATED); + /** * Command. * * @author Fabien Potencier + * + * @deprecated since Symfony 4.2, use {@see Command} instead. */ abstract class ContainerAwareCommand extends Command implements ContainerAwareInterface { diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php index 7dced9e64898a..6ac413a226fd3 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php @@ -101,6 +101,10 @@ public function testBundleCommandCanBeFoundByAlias() $this->assertSame($command, $application->find('alias')); } + /** + * @group legacy + * @expectedDeprecation The "Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand" class is deprecated since Symfony 4.2, use "Symfony\Component\Console\Command\Command" with dependency injection instead. + */ public function testBundleCommandsHaveRightContainer() { $command = $this->getMockForAbstractClass('Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand', array('foo'), '', true, true, true, array('setContainer'));