/** * @param Application $application */ public function registerCustomCommands(Application $application) { foreach ($this->getArray(array('commands', 'customCommands')) as $commandClass) { $commandName = null; if (is_array($commandClass)) { // Support for key => value (name -> class) $commandName = key($commandClass); $commandClass = current($commandClass); } if (null === ($command = $this->newCommand($commandClass, $commandName))) { $this->output->writeln(sprintf('<error>Can not add nonexistent command class "%s" as command to the application</error>', $commandClass, $commandName)); $this->debugWriteln('Please check the configuration files contain the correct class-name. If the ' . 'class-name is correct, check autoloader configurations.'); } else { $this->debugWriteln(sprintf('<debug>Add command </debug> <info>%s</info> -> <comment>%s</comment>', $command->getName(), get_class($command))); $application->add($command); } } }
/** * @param Application $application */ public function registerCustomCommands(Application $application) { if (isset($this->config['commands']['customCommands']) && is_array($this->config['commands']['customCommands'])) { foreach ($this->config['commands']['customCommands'] as $commandClass) { if (is_array($commandClass)) { // Support for key => value (name -> class) $resolvedCommandClass = current($commandClass); /** @var Command $command */ $command = new $resolvedCommandClass(); $command->setName(key($commandClass)); } else { /** @var Command $command */ $command = new $commandClass(); } $application->add($command); $output = $this->output; if (OutputInterface::VERBOSITY_DEBUG <= $output->getVerbosity()) { $output->writeln('<debug>Added command </debug><comment>' . get_class($command) . '</comment>'); } } } }
/** * @param Application $application */ public function registerCustomCommands(Application $application) { foreach ($this->getArray(array('commands', 'customCommands')) as $commandClass) { $commandName = null; if (is_array($commandClass)) { // Support for key => value (name -> class) $commandName = key($commandClass); $commandClass = current($commandClass); } $command = $this->newCommand($commandClass, $commandName); $this->debugWriteln(sprintf('<debug>Add command </debug> <info>%s</info> -> <comment>%s</comment>', $command->getName(), get_class($command))); $application->add($command); } }