/** * 添加一个指令 * @param Command $command * @return Command */ public function add(Command $command) { $command->setConsole($this); if (!$command->isEnabled()) { $command->setConsole(null); return null; } if (null === $command->getDefinition()) { throw new \LogicException(sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', get_class($command))); } $this->commands[$command->getName()] = $command; foreach ($command->getAliases() as $alias) { $this->commands[$alias] = $command; } return $command; }