[HttpKernel] Deprecated commands auto-registration
This commit is contained in:
parent
736f0d0d93
commit
14215d8185
@ -114,6 +114,35 @@ FrameworkBundle
|
|||||||
class has been deprecated and will be removed in 4.0. Use the
|
class has been deprecated and will be removed in 4.0. Use the
|
||||||
`Symfony\Component\Translation\DependencyInjection\TranslatorPass` class instead.
|
`Symfony\Component\Translation\DependencyInjection\TranslatorPass` class instead.
|
||||||
|
|
||||||
|
HttpKernel
|
||||||
|
----------
|
||||||
|
|
||||||
|
* Relying on convention-based commands discovery has been deprecated and
|
||||||
|
won't be supported in 4.0. Use PSR-4 based service discovery instead.
|
||||||
|
|
||||||
|
Before:
|
||||||
|
|
||||||
|
```yml
|
||||||
|
# app/config/services.yml
|
||||||
|
services:
|
||||||
|
# ...
|
||||||
|
|
||||||
|
# implicit registration of all commands in the `Command` folder
|
||||||
|
```
|
||||||
|
|
||||||
|
After:
|
||||||
|
|
||||||
|
```yml
|
||||||
|
# app/config/services.yml
|
||||||
|
services:
|
||||||
|
# ...
|
||||||
|
|
||||||
|
# explicit commands registration
|
||||||
|
AppBundle\Command:
|
||||||
|
resource: '../../src/AppBundle/Command/*'
|
||||||
|
tags: ['console.command']
|
||||||
|
```
|
||||||
|
|
||||||
Process
|
Process
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
@ -452,6 +452,32 @@ HttpFoundation
|
|||||||
HttpKernel
|
HttpKernel
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
* Relying on convention-based commands discovery is not supported anymore.
|
||||||
|
Use PSR-4 based service discovery instead.
|
||||||
|
|
||||||
|
Before:
|
||||||
|
|
||||||
|
```yml
|
||||||
|
# app/config/services.yml
|
||||||
|
services:
|
||||||
|
# ...
|
||||||
|
|
||||||
|
# implicit registration of all commands in the `Command` folder
|
||||||
|
```
|
||||||
|
|
||||||
|
After:
|
||||||
|
|
||||||
|
```yml
|
||||||
|
# app/config/services.yml
|
||||||
|
services:
|
||||||
|
# ...
|
||||||
|
|
||||||
|
# explicit commands registration
|
||||||
|
AppBundle\Command:
|
||||||
|
resource: '../../src/AppBundle/Command/*'
|
||||||
|
tags: ['console.command']
|
||||||
|
```
|
||||||
|
|
||||||
* Removed the `kernel.root_dir` parameter. Use the `kernel.project_dir` parameter
|
* Removed the `kernel.root_dir` parameter. Use the `kernel.project_dir` parameter
|
||||||
instead.
|
instead.
|
||||||
|
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
# to be removed once https://github.com/doctrine/DoctrineBundle/pull/684 is merged
|
||||||
|
services:
|
||||||
|
Doctrine\Bundle\DoctrineBundle\Command\:
|
||||||
|
resource: "@DoctrineBundle/Command/*"
|
||||||
|
tags: [console.command]
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Bundle\SecurityBundle\Tests\Functional\app;
|
namespace Symfony\Bundle\SecurityBundle\Tests\Functional\app;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Version;
|
||||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||||
use Symfony\Component\Filesystem\Filesystem;
|
use Symfony\Component\Filesystem\Filesystem;
|
||||||
use Symfony\Component\HttpKernel\Kernel;
|
use Symfony\Component\HttpKernel\Kernel;
|
||||||
@ -82,6 +83,11 @@ class AppKernel extends Kernel
|
|||||||
public function registerContainerConfiguration(LoaderInterface $loader)
|
public function registerContainerConfiguration(LoaderInterface $loader)
|
||||||
{
|
{
|
||||||
$loader->load($this->rootConfig);
|
$loader->load($this->rootConfig);
|
||||||
|
|
||||||
|
// to be removed once https://github.com/doctrine/DoctrineBundle/pull/684 is merged
|
||||||
|
if ('Acl' === $this->testCase && class_exists(Version::class)) {
|
||||||
|
$loader->load(__DIR__.'/Acl/doctrine.yml');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function serialize()
|
public function serialize()
|
||||||
|
@ -191,6 +191,8 @@ abstract class Bundle implements BundleInterface
|
|||||||
}
|
}
|
||||||
$r = new \ReflectionClass($class);
|
$r = new \ReflectionClass($class);
|
||||||
if ($r->isSubclassOf('Symfony\\Component\\Console\\Command\\Command') && !$r->isAbstract() && !$r->getConstructor()->getNumberOfRequiredParameters()) {
|
if ($r->isSubclassOf('Symfony\\Component\\Console\\Command\\Command') && !$r->isAbstract() && !$r->getConstructor()->getNumberOfRequiredParameters()) {
|
||||||
|
@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);
|
||||||
|
|
||||||
$application->add($r->newInstance());
|
$application->add($r->newInstance());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ CHANGELOG
|
|||||||
3.4.0
|
3.4.0
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
* deprecated commands auto registration
|
||||||
* added `AddCacheClearerPass`
|
* added `AddCacheClearerPass`
|
||||||
* added `AddCacheWarmerPass`
|
* added `AddCacheWarmerPass`
|
||||||
|
|
||||||
|
@ -31,6 +31,10 @@ class BundleTest extends TestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group legacy
|
||||||
|
* @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.
|
||||||
|
*/
|
||||||
public function testRegisterCommands()
|
public function testRegisterCommands()
|
||||||
{
|
{
|
||||||
$cmd = new FooCommand();
|
$cmd = new FooCommand();
|
||||||
|
Reference in New Issue
Block a user