public registerCustomCommands ( |
||
$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 array $initConfig [optional] * @param InputInterface $input [optional] * @param OutputInterface $output [optional] * * @return void */ public function init(array $initConfig = array(), InputInterface $input = null, OutputInterface $output = null) { if ($this->_isInitialized) { return; } // Suppress DateTime warnings date_default_timezone_set(@date_default_timezone_get()); // Initialize EventDispatcher early $this->dispatcher = new EventDispatcher(); $this->setDispatcher($this->dispatcher); $input = $input ?: new ArgvInput(); $output = $output ?: new ConsoleOutput(); if (null !== $this->config) { throw new UnexpectedValueException(sprintf('Config already initialized')); } $loadExternalConfig = !$input->hasParameterOption('--skip-config'); $this->config = $config = new Config($initConfig, $this->isPharMode(), $output); if ($this->configurationLoaderInjected) { $config->setLoader($this->configurationLoaderInjected); } $config->loadPartialConfig($loadExternalConfig); $this->detectMagento($input, $output); $configLoader = $config->getLoader(); $configLoader->loadStageTwo($this->_magentoRootFolder, $loadExternalConfig, $this->_magerunStopFileFolder); $config->load(); if ($autoloader = $this->autoloader) { $config->registerCustomAutoloaders($autoloader); $this->registerEventSubscribers(); $config->registerCustomCommands($this); } $this->registerHelpers(); $this->_isInitialized = true; }