Fix lazy commands registration

This commit is contained in:
Robin Chalas 2017-07-15 14:12:51 +02:00
parent b24a338f71
commit f25a8b5c41
2 changed files with 4 additions and 3 deletions

View File

@ -466,7 +466,6 @@ class Application
$command = $this->commands[$name];
} elseif ($this->commandLoader && $this->commandLoader->has($name)) {
$command = $this->commandLoader->get($name);
$command->setName($name);
$this->add($command);
} else {
throw new CommandNotFoundException(sprintf('The command "%s" does not exist.', $name));
@ -647,7 +646,7 @@ class Application
$commands = $this->commands;
foreach ($this->commandLoader->getNames() as $name) {
if (!isset($commands[$name])) {
$commands[$name] = $this->commandLoader->get($name);
$commands[$name] = $this->get($name);
}
}
@ -664,7 +663,7 @@ class Application
if ($this->commandLoader) {
foreach ($this->commandLoader->getNames() as $name) {
if (!isset($commands[$name]) && $namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1)) {
$commands[$name] = $this->commandLoader->get($name);
$commands[$name] = $this->get($name);
}
}
}

View File

@ -87,6 +87,8 @@ class AddConsoleCommandPass implements CompilerPassInterface
}
}
$definition->addMethodCall('setName', array($commandName));
if ($aliases) {
$definition->addMethodCall('setAliases', array($aliases));
}