Skip to content

Commit

Permalink
[chain] Avoid overwrite chain command options with global/default opt…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
enzolutions committed May 25, 2017
1 parent 9c76535 commit 1096794
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 7 additions & 5 deletions src/Command/Chain/ChainCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand All @@ -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;
}
}
Expand Down

0 comments on commit 1096794

Please sign in to comment.