Skip to content

Commit f25a8b5

Browse files
author
Robin Chalas
committed
Fix lazy commands registration
1 parent b24a338 commit f25a8b5

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/Symfony/Component/Console/Application.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,6 @@ public function get($name)
466466
$command = $this->commands[$name];
467467
} elseif ($this->commandLoader && $this->commandLoader->has($name)) {
468468
$command = $this->commandLoader->get($name);
469-
$command->setName($name);
470469
$this->add($command);
471470
} else {
472471
throw new CommandNotFoundException(sprintf('The command "%s" does not exist.', $name));
@@ -647,7 +646,7 @@ public function all($namespace = null)
647646
$commands = $this->commands;
648647
foreach ($this->commandLoader->getNames() as $name) {
649648
if (!isset($commands[$name])) {
650-
$commands[$name] = $this->commandLoader->get($name);
649+
$commands[$name] = $this->get($name);
651650
}
652651
}
653652

@@ -664,7 +663,7 @@ public function all($namespace = null)
664663
if ($this->commandLoader) {
665664
foreach ($this->commandLoader->getNames() as $name) {
666665
if (!isset($commands[$name]) && $namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1)) {
667-
$commands[$name] = $this->commandLoader->get($name);
666+
$commands[$name] = $this->get($name);
668667
}
669668
}
670669
}

src/Symfony/Component/Console/DependencyInjection/AddConsoleCommandPass.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ public function process(ContainerBuilder $container)
8787
}
8888
}
8989

90+
$definition->addMethodCall('setName', array($commandName));
91+
9092
if ($aliases) {
9193
$definition->addMethodCall('setAliases', array($aliases));
9294
}

0 commit comments

Comments
 (0)