12 namespace Symfony\Component\Console\Descriptor;
68 if (null === $this->namespaces) {
69 $this->inspectApplication();
80 if (null === $this->commands) {
81 $this->inspectApplication();
96 if (!isset($this->commands[$name]) && !isset($this->aliases[$name])) {
97 throw new \InvalidArgumentException(sprintf(
'Command %s does not exist.', $name));
100 return isset($this->commands[$name]) ? $this->commands[$name] : $this->aliases[$name];
103 private function inspectApplication()
105 $this->commands = array();
106 $this->namespaces = array();
108 $all = $this->application->all($this->
namespace ? $this->application->findNamespace($this->namespace) : null);
113 foreach (
$commands as $name => $command) {
114 if (!$command->getName()) {
118 if ($command->getName() === $name) {
119 $this->commands[$name] = $command;
121 $this->aliases[$name] = $command;
127 $this->namespaces[
$namespace] = array(
'id' => $namespace,
'commands' => $names);
138 $namespacedCommands = array();
139 foreach ($commands as $name => $command) {
140 $key = $this->application->extractNamespace($name, 1);
145 $namespacedCommands[$key][$name] = $command;
147 ksort($namespacedCommands);
149 foreach ($namespacedCommands as &$commandsSet) {
155 return $namespacedCommands;