mirror of
https://github.com/hauke68/Magallanes.git
synced 2026-08-28 18:18:57 +02:00
[Nostromo] Refactor config load
This commit is contained in:
@@ -66,4 +66,12 @@ abstract class AbstractCommand extends Command
|
||||
$utils = new Utils();
|
||||
return $utils->getStageName($this->runtime->getStage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Requires the configuration to be loaded
|
||||
*/
|
||||
protected function requireConfig()
|
||||
{
|
||||
$this->getApplication()->configure();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,8 @@ class DumpCommand extends AbstractCommand
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->requireConfig();
|
||||
|
||||
$output->writeln('Starting <fg=blue>Magallanes</>');
|
||||
$output->writeln('');
|
||||
|
||||
|
||||
@@ -42,6 +42,8 @@ class EnvironmentsCommand extends AbstractCommand
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->requireConfig();
|
||||
|
||||
$output->writeln('Starting <fg=blue>Magallanes</>');
|
||||
$output->writeln('');
|
||||
|
||||
|
||||
@@ -58,6 +58,8 @@ class DeployCommand extends AbstractCommand
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->requireConfig();
|
||||
|
||||
$output->writeln('Starting <fg=blue>Magallanes</>');
|
||||
$output->writeln('');
|
||||
|
||||
|
||||
@@ -51,6 +51,8 @@ class ListCommand extends AbstractCommand
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->requireConfig();
|
||||
|
||||
$utils = new Utils();
|
||||
$output->writeln('Starting <fg=blue>Magallanes</>');
|
||||
$output->writeln('');
|
||||
|
||||
@@ -52,6 +52,8 @@ class RollbackCommand extends DeployCommand
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->requireConfig();
|
||||
|
||||
$output->writeln('Starting <fg=blue>Magallanes</>');
|
||||
$output->writeln('');
|
||||
|
||||
|
||||
@@ -40,9 +40,11 @@ class MageApplication extends Application
|
||||
*/
|
||||
public function __construct($file)
|
||||
{
|
||||
$this->file = $file;
|
||||
parent::__construct('Magallanes', Mage::VERSION);
|
||||
|
||||
$this->file = $file;
|
||||
$dispatcher = new EventDispatcher();
|
||||
$this->setDispatcher($dispatcher);
|
||||
|
||||
$dispatcher->addListener(ConsoleEvents::EXCEPTION, function (ConsoleExceptionEvent $event) {
|
||||
$output = $event->getOutput();
|
||||
@@ -52,8 +54,8 @@ class MageApplication extends Application
|
||||
$event->setException(new \LogicException('Caught exception', $exitCode, $event->getException()));
|
||||
});
|
||||
|
||||
$this->setDispatcher($dispatcher);
|
||||
parent::__construct('Magallanes', Mage::VERSION);
|
||||
$this->runtime = $this->instantiateRuntime();
|
||||
$this->loadBuiltInCommands();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,12 +87,9 @@ class MageApplication extends Application
|
||||
$logger->pushHandler(new StreamHandler($logfile));
|
||||
}
|
||||
|
||||
$this->runtime = $this->instantiateRuntime();
|
||||
$this->runtime->setConfiguration($config['magephp']);
|
||||
$this->runtime->setLogger($logger);
|
||||
|
||||
$this->loadBuiltInCommands();
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
throw new RuntimeException(sprintf('The file "%s" does not have a valid Magallanes configuration.', $this->file));
|
||||
|
||||
Reference in New Issue
Block a user