bug #41214 [Console] fix registering command aliases when using the new "cmd|alias" syntax for names (nicolas-grekas)
This PR was merged into the 5.3-dev branch.
Discussion
----------
[Console] fix registering command aliases when using the new "cmd|alias" syntax for names
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Fix #41212
| License | MIT
| Doc PR | -
Commits
-------
6633b95597
[Console] fix registering command aliases when using the new "cmd|alias" syntax for names
This commit is contained in:
commit
c61617e6ac
@ -94,6 +94,10 @@ class AddConsoleCommandPass implements CompilerPassInterface
|
|||||||
$lazyCommandMap[$commandName] = $id;
|
$lazyCommandMap[$commandName] = $id;
|
||||||
$lazyCommandRefs[$id] = new TypedReference($id, $class);
|
$lazyCommandRefs[$id] = new TypedReference($id, $class);
|
||||||
|
|
||||||
|
foreach ($aliases as $alias) {
|
||||||
|
$lazyCommandMap[$alias] = $id;
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($tags as $tag) {
|
foreach ($tags as $tag) {
|
||||||
if (isset($tag['command'])) {
|
if (isset($tag['command'])) {
|
||||||
$aliases[] = $tag['command'];
|
$aliases[] = $tag['command'];
|
||||||
|
@ -135,7 +135,7 @@ class AddConsoleCommandPassTest extends TestCase
|
|||||||
$commandLocator = $container->getDefinition((string) $commandLoader->getArgument(0));
|
$commandLocator = $container->getDefinition((string) $commandLoader->getArgument(0));
|
||||||
|
|
||||||
$this->assertSame(ContainerCommandLoader::class, $commandLoader->getClass());
|
$this->assertSame(ContainerCommandLoader::class, $commandLoader->getClass());
|
||||||
$this->assertSame(['cmdname' => 'with-defaults'], $commandLoader->getArgument(1));
|
$this->assertSame(['cmdname' => 'with-defaults', 'cmdalias' => 'with-defaults'], $commandLoader->getArgument(1));
|
||||||
$this->assertEquals([['with-defaults' => new ServiceClosureArgument(new Reference('.with-defaults.lazy'))]], $commandLocator->getArguments());
|
$this->assertEquals([['with-defaults' => new ServiceClosureArgument(new Reference('.with-defaults.lazy'))]], $commandLocator->getArguments());
|
||||||
$this->assertSame([], $container->getParameter('console.command.ids'));
|
$this->assertSame([], $container->getParameter('console.command.ids'));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user