Skip to content

Commit 2fa948d

Browse files
committed
minor #23533 [Console] Application is not responsible for setting the name of lazy commands (chalasr)
This PR was merged into the 3.4 branch. Discussion ---------- [Console] Application is not responsible for setting the name of lazy commands | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Fixes `all` not calling `get()` for lazy commands and stop setting the command name from Application (the command loader is responsible for returning valid commands). Commits ------- f25a8b5 Fix lazy commands registration
2 parents dd6fc4b + f25a8b5 commit 2fa948d

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)