[Nostromo] Refactor config test

This commit is contained in:
Andrés Montañez 2017-01-29 18:10:41 -03:00
parent 4bf8babf46
commit 092006db91

View file

@ -70,20 +70,19 @@ class MageApplication extends Application
throw new RuntimeException(sprintf('Error parsing the file "%s".', $file));
}
if (array_key_exists('magephp', $config)) {
$config = is_null($config['magephp']) ? [] : $config['magephp'];
if (array_key_exists('magephp', $config) && is_array($config['magephp'])) {
$logger = null;
if (array_key_exists('log_dir', $config) && file_exists($config['log_dir']) && is_dir($config['log_dir'])) {
$logfile = sprintf('%s/%s.log', $config['log_dir'], date('Ymd_His'));
$config['log_file'] = $logfile;
if (array_key_exists('log_dir', $config['magephp']) && file_exists($config['magephp']['log_dir']) && is_dir($config['magephp']['log_dir'])) {
$logfile = sprintf('%s/%s.log', $config['magephp']['log_dir'], date('Ymd_His'));
$config['magephp']['log_file'] = $logfile;
$logger = new Logger('magephp');
$logger->pushHandler(new StreamHandler($logfile));
}
$this->runtime = $this->instantiateRuntime();
$this->runtime->setConfiguration($config);
$this->runtime->setConfiguration($config['magephp']);
$this->runtime->setLogger($logger);
$this->loadBuiltInCommands();