Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2536345

Browse files
committed
feature #23805 [HttpKernel] Deprecated commands auto-registration (GuilhemN)
This PR was squashed before being merged into the 3.4 branch (closes #23805). Discussion ---------- [HttpKernel] Deprecated commands auto-registration | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | no <!-- don't forget updating src/**/CHANGELOG.md files --> | BC breaks? | no | Deprecations? | yes <!-- don't forget updating UPGRADE-*.md files --> | Tests pass? | yes | Fixed tickets | #23488 | License | MIT | Doc PR | Deprecates commands auto-registration. See #23488 for arguments. Commits ------- 14215d8 [HttpKernel] Deprecated commands auto-registration
2 parents 1a9a254 + 14215d8 commit 2536345

File tree

7 files changed

+73
-0
lines changed

7 files changed

+73
-0
lines changed

UPGRADE-3.4.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,35 @@ FrameworkBundle
114114
class has been deprecated and will be removed in 4.0. Use the
115115
`Symfony\Component\Translation\DependencyInjection\TranslatorPass` class instead.
116116

117+
HttpKernel
118+
----------
119+
120+
* Relying on convention-based commands discovery has been deprecated and
121+
won't be supported in 4.0. Use PSR-4 based service discovery instead.
122+
123+
Before:
124+
125+
```yml
126+
# app/config/services.yml
127+
services:
128+
# ...
129+
130+
# implicit registration of all commands in the `Command` folder
131+
```
132+
133+
After:
134+
135+
```yml
136+
# app/config/services.yml
137+
services:
138+
# ...
139+
140+
# explicit commands registration
141+
AppBundle\Command:
142+
resource: '../../src/AppBundle/Command/*'
143+
tags: ['console.command']
144+
```
145+
117146
Process
118147
-------
119148

UPGRADE-4.0.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,32 @@ HttpFoundation
452452
HttpKernel
453453
----------
454454

455+
* Relying on convention-based commands discovery is not supported anymore.
456+
Use PSR-4 based service discovery instead.
457+
458+
Before:
459+
460+
```yml
461+
# app/config/services.yml
462+
services:
463+
# ...
464+
465+
# implicit registration of all commands in the `Command` folder
466+
```
467+
468+
After:
469+
470+
```yml
471+
# app/config/services.yml
472+
services:
473+
# ...
474+
475+
# explicit commands registration
476+
AppBundle\Command:
477+
resource: '../../src/AppBundle/Command/*'
478+
tags: ['console.command']
479+
```
480+
455481
* Removed the `kernel.root_dir` parameter. Use the `kernel.project_dir` parameter
456482
instead.
457483

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# to be removed once https://github.com/doctrine/DoctrineBundle/pull/684 is merged
2+
services:
3+
Doctrine\Bundle\DoctrineBundle\Command\:
4+
resource: "@DoctrineBundle/Command/*"
5+
tags: [console.command]

src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bundle\SecurityBundle\Tests\Functional\app;
1313

14+
use Doctrine\ORM\Version;
1415
use Symfony\Component\Config\Loader\LoaderInterface;
1516
use Symfony\Component\Filesystem\Filesystem;
1617
use Symfony\Component\HttpKernel\Kernel;
@@ -82,6 +83,11 @@ public function getLogDir()
8283
public function registerContainerConfiguration(LoaderInterface $loader)
8384
{
8485
$loader->load($this->rootConfig);
86+
87+
// to be removed once https://github.com/doctrine/DoctrineBundle/pull/684 is merged
88+
if ('Acl' === $this->testCase && class_exists(Version::class)) {
89+
$loader->load(__DIR__.'/Acl/doctrine.yml');
90+
}
8591
}
8692

8793
public function serialize()

src/Symfony/Component/HttpKernel/Bundle/Bundle.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ public function registerCommands(Application $application)
191191
}
192192
$r = new \ReflectionClass($class);
193193
if ($r->isSubclassOf('Symfony\\Component\\Console\\Command\\Command') && !$r->isAbstract() && !$r->getConstructor()->getNumberOfRequiredParameters()) {
194+
@trigger_error(sprintf('Auto-registration of the command "%s" is deprecated since Symfony 3.4 and won\'t be supported in 4.0. Use PSR-4 based service discovery instead.', $class), E_USER_DEPRECATED);
195+
194196
$application->add($r->newInstance());
195197
}
196198
}

src/Symfony/Component/HttpKernel/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CHANGELOG
44
3.4.0
55
-----
66

7+
* deprecated commands auto registration
78
* added `AddCacheClearerPass`
89
* added `AddCacheWarmerPass`
910

src/Symfony/Component/HttpKernel/Tests/Bundle/BundleTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ public function testGetContainerExtension()
3131
);
3232
}
3333

34+
/**
35+
* @group legacy
36+
* @expectedDeprecation Auto-registration of the command "Symfony\Component\HttpKernel\Tests\Fixtures\ExtensionPresentBundle\Command\FooCommand" is deprecated since Symfony 3.4 and won't be supported in 4.0. Use PSR-4 based service discovery instead.
37+
*/
3438
public function testRegisterCommands()
3539
{
3640
$cmd = new FooCommand();

0 commit comments

Comments
 (0)