From 109679411bd910e7d25e5b009bfe3538eb99b77c Mon Sep 17 00:00:00 2001 From: enzo - Eduardo Garcia Date: Thu, 25 May 2017 11:18:30 +1000 Subject: [PATCH] [chain] Avoid overwrite chain command options with global/default options --- services.yml | 2 +- src/Command/Chain/ChainCommand.php | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/services.yml b/services.yml index 09f1177..f5dcc99 100644 --- a/services.yml +++ b/services.yml @@ -7,7 +7,7 @@ services: console.requirement_checker: class: Drupal\Console\Core\Utils\RequirementChecker console.chain_queue: - class: Drupal\Console\Core\Utils\ChainQueue + class: Drupal\Console\Core\Uconsole.init_generatortils\ChainQueue console.nested_array: class: Drupal\Console\Core\Utils\NestedArray console.show_file: diff --git a/src/Command/Chain/ChainCommand.php b/src/Command/Chain/ChainCommand.php index 5191af1..5fdf711 100644 --- a/src/Command/Chain/ChainCommand.php +++ b/src/Command/Chain/ChainCommand.php @@ -294,8 +294,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $commands = $configData['commands']; } - $parameterOptions = $input->getOptions(); - unset($parameterOptions['file']); + $chainInlineOptions = $input->getOptions(); + unset($chainInlineOptions['file']); foreach ($commands as $command) { $moduleInputs = []; @@ -310,11 +310,13 @@ protected function execute(InputInterface $input, OutputInterface $output) $moduleInputs['--'.$key] = is_null($value) ? '' : $value; } + // Get application global options foreach ($this->getApplication()->getDefinition()->getOptions() as $option) { $optionName = $option->getName(); - if (array_key_exists($optionName, $parameterOptions)) { - $optionValue = $parameterOptions[$optionName]; - if ($optionValue) { + if (array_key_exists($optionName, $chainInlineOptions)) { + $optionValue = $chainInlineOptions[$optionName]; + // Set global option only if is not available in command options + if (!isset($moduleInputs['--' . $optionName]) && $optionValue) { $moduleInputs['--' . $optionName] = $optionValue; } }