Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions src/Command/Shared/InputTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
* Class InputTrait
*
* @package Drupal\Console\Core\Command
* @package Drupal\Console\Core\Command\Shared
*/
trait InputTrait
{
Expand All @@ -19,19 +19,17 @@ trait InputTrait
*/
private function inlineValueAsArray($inputValue)
{
$inputArrayValue = [];
$inputAsArray = [];
foreach ($inputValue as $key => $value) {
if (!is_array($value)) {
$separatorIndex = strpos($value, ':');
if (!$separatorIndex) {
try {
$inputAsArray[] = json_decode('[{'.$value.'}]', true)[0];
} catch (\Exception $e) {
continue;
}
$inputKeyItem = substr($value, 0, $separatorIndex);
$inputValueItem = substr($value, $separatorIndex+1);
$inputArrayValue[$key] = [$inputKeyItem => $inputValueItem];
}
}

return $inputArrayValue?$inputArrayValue:$inputValue;
return $inputAsArray?$inputAsArray:$inputValue;
}
}
3 changes: 2 additions & 1 deletion src/EventSubscriber/ShowGenerateChainListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class ShowGenerateChainListener implements EventSubscriberInterface
private $skipOptions = [
'env',
'generate-inline',
'generate-chain'
'generate-chain',
'no-interaction'
];

/**
Expand Down
11 changes: 6 additions & 5 deletions src/EventSubscriber/ShowGenerateInlineListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ class ShowGenerateInlineListener implements EventSubscriberInterface
private $skipOptions = [
'env',
'generate-inline',
'generate-chain'
'generate-chain',
'no-interaction'
];

/**
Expand Down Expand Up @@ -115,9 +116,9 @@ public function showGenerateInline(ConsoleTerminateEvent $event)
foreach ($optionValue as $optionItem) {
if (is_array($optionItem)) {
$inlineValue = implode(
' ', array_map(
', ', array_map(
function ($v, $k) {
return $k . ':' . $v;
return '"'.$k . '":"' . $v . '"';
},
$optionItem,
array_keys($optionItem)
Expand All @@ -126,7 +127,7 @@ function ($v, $k) {
} else {
$inlineValue = $optionItem;
}
$inline .= ' --' . $optionName . '="' . $inlineValue . '"';
$inline .= ' --' . $optionName . '=\'' . $inlineValue . '\'';
}
} else {
if (is_bool($optionValue)) {
Expand All @@ -144,7 +145,7 @@ function ($v, $k) {

$io->writeln(
sprintf(
'$ drupal %s %s',
'$ drupal %s %s --no-interaction',
$command_name,
$inline
)
Expand Down