Skip to content

Commit

Permalink
[console] Relocate command registration to loadCommands method. (#308)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmolivas committed Feb 9, 2018
1 parent a80391b commit 7bbdebd
Showing 1 changed file with 28 additions and 16 deletions.
44 changes: 28 additions & 16 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,29 +113,14 @@ public function doRun(InputInterface $input, OutputInterface $output)
$output->write(sprintf("\033\143"));
}

$this->registerGenerators();
$this->registerCommands();
$this->registerEvents();
$this->registerExtendCommands();
$this->loadCommands();

/**
* @var ConfigurationManager $configurationManager
*/
$configurationManager = $this->container
->get('console.configuration_manager');

$config = $configurationManager->getConfiguration()
->get('application.extras.config')?:'true';
if ($config === 'true') {
$this->registerCommandsFromAutoWireConfiguration();
}

$chains = $configurationManager->getConfiguration()
->get('application.extras.chains')?:'true';
if ($chains === 'true') {
$this->registerChainCommands();
}

if (!$this->has($this->commandName)) {
$isValidCommand = false;
$config = $configurationManager->getConfiguration();
Expand Down Expand Up @@ -199,6 +184,7 @@ public function doRun(InputInterface $input, OutputInterface $output)
$input,
$output
);

if ($this->showMessages($input)) {
$messages = $messageManager->getMessages();

Expand All @@ -216,6 +202,32 @@ public function doRun(InputInterface $input, OutputInterface $output)
return $code;
}

public function loadCommands()
{
$this->registerGenerators();
$this->registerCommands();
$this->registerEvents();
$this->registerExtendCommands();

/**
* @var ConfigurationManager $configurationManager
*/
$configurationManager = $this->container
->get('console.configuration_manager');

$config = $configurationManager->getConfiguration()
->get('application.extras.config')?:'true';
if ($config === 'true') {
$this->registerCommandsFromAutoWireConfiguration();
}

$chains = $configurationManager->getConfiguration()
->get('application.extras.chains')?:'true';
if ($chains === 'true') {
$this->registerChainCommands();
}
}

/**
* @param InputInterface $input
*
Expand Down

0 comments on commit 7bbdebd

Please sign in to comment.