Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ed5ddf9

Browse filesBrowse files
committed
feature #28415 [FrameworkBundle] Deprecate ContainerAwareCommand (chalasr)
This PR was merged into the 4.2-dev branch. Discussion ---------- [FrameworkBundle] Deprecate ContainerAwareCommand | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | symfony/symfony-docs#10307 Follow up of the recent `Controller` deprecation. I think people are widely used to register their commands as services and use proper dependency injection, we made the move for core commands in 3.4, let's deprecate `ContainerAwareCommand` for 4.2. Commits ------- 744bf0e [FrameworkBundle] Deprecate ContainerAwareCommand
2 parents 766a82b + 744bf0e commit ed5ddf9
Copy full SHA for ed5ddf9

File tree

Expand file treeCollapse file tree

5 files changed

+15
-2
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+15
-2
lines changed

‎UPGRADE-4.2.md

Copy file name to clipboardExpand all lines: UPGRADE-4.2.md
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ FrameworkBundle
102102
serializer:
103103
id: your_messenger_service_id
104104
```
105+
* The `ContainerAwareCommand` class has been deprecated, use `Symfony\Component\Console\Command\Command`
106+
with dependency injection instead.
105107

106108
Messenger
107109
---------

‎UPGRADE-5.0.md

Copy file name to clipboardExpand all lines: UPGRADE-5.0.md
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ FrameworkBundle
9393
* The `RequestDataCollector` class has been removed. Use the `Symfony\Component\HttpKernel\DataCollector\RequestDataCollector` class instead.
9494
* Removed `Symfony\Bundle\FrameworkBundle\Controller\Controller`. Use `Symfony\Bundle\FrameworkBundle\Controller\AbstractController` instead.
9595
* 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.
96+
* The `ContainerAwareCommand` class has been removed, use `Symfony\Component\Console\Command\Command`
97+
with dependency injection instead.
9698

9799
HttpFoundation
98100
--------------

‎src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ CHANGELOG
1111
* Deprecated the `Symfony\Bundle\FrameworkBundle\Controller\Controller` class in favor of `Symfony\Bundle\FrameworkBundle\Controller\AbstractController`.
1212
* Enabled autoconfiguration for `Psr\Log\LoggerAwareInterface`
1313
* Added new "auto" mode for `framework.session.cookie_secure` to turn it on when HTTPS is used
14-
* Removed the `framework.messenger.encoder` and `framework.messenger.decoder` options. Use the `framework.messenger.serializer.id` option to replace the Messenger serializer.
15-
14+
* Removed the `framework.messenger.encoder` and `framework.messenger.decoder` options. Use the `framework.messenger.serializer.id` option to replace the Messenger serializer.
15+
* Deprecated the `ContainerAwareCommand` class in favor of `Symfony\Component\Console\Command\Command`
16+
1617
4.1.0
1718
-----
1819

‎src/Symfony/Bundle/FrameworkBundle/Command/ContainerAwareCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/ContainerAwareCommand.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@
1515
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
1616
use Symfony\Component\DependencyInjection\ContainerInterface;
1717

18+
@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);
19+
1820
/**
1921
* Command.
2022
*
2123
* @author Fabien Potencier <fabien@symfony.com>
24+
*
25+
* @deprecated since Symfony 4.2, use {@see Command} instead.
2226
*/
2327
abstract class ContainerAwareCommand extends Command implements ContainerAwareInterface
2428
{

‎src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Console/ApplicationTest.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ public function testBundleCommandCanBeFoundByAlias()
101101
$this->assertSame($command, $application->find('alias'));
102102
}
103103

104+
/**
105+
* @group legacy
106+
* @expectedDeprecation The "Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand" class is deprecated since Symfony 4.2, use "Symfony\Component\Console\Command\Command" with dependency injection instead.
107+
*/
104108
public function testBundleCommandsHaveRightContainer()
105109
{
106110
$command = $this->getMockForAbstractClass('Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand', array('foo'), '', true, true, true, array('setContainer'));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.