diff --git a/setup/src/Magento/Setup/Console/Command/InstallCommand.php b/setup/src/Magento/Setup/Console/Command/InstallCommand.php index 467e94febef39..a2e8715b02233 100644 --- a/setup/src/Magento/Setup/Console/Command/InstallCommand.php +++ b/setup/src/Magento/Setup/Console/Command/InstallCommand.php @@ -169,6 +169,14 @@ protected function initialize(InputInterface $input, OutputInterface $output) } } + if ($inputOptions['interactive']) { + $command = ''; + foreach ($configOptionsToValidate as $key => $value) { + $command .= " --{$key}={$value}"; + } + $output->writeln("Try re-running command: php bin/magento setup:install{$command}"); + } + $errors = $this->configModel->validate($configOptionsToValidate); $errors = array_merge($errors, $this->adminUser->validate($input)); $errors = array_merge($errors, $this->validate($input)); @@ -226,6 +234,8 @@ private function interactiveQuestions(InputInterface $input, OutputInterface $ou ); } + $output->writeln(""); + foreach ($this->userConfig->getOptionsList() as $option) { $configOptionsToValidate[$option->getName()] = $this->askQuestion( $input, @@ -235,6 +245,8 @@ private function interactiveQuestions(InputInterface $input, OutputInterface $ou ); } + $output->writeln(""); + foreach ($this->adminUser->getOptionsList() as $option) { $configOptionsToValidate[$option->getName()] = $this->askQuestion( $input, @@ -243,7 +255,17 @@ private function interactiveQuestions(InputInterface $input, OutputInterface $ou $option ); } - return $configOptionsToValidate; + + $output->writeln(""); + + $returnConfigOptionsToValidate = []; + foreach ($configOptionsToValidate as $key => $value) { + if ($value != '') { + $returnConfigOptionsToValidate[$key] = $value; + } + } + + return $returnConfigOptionsToValidate; } /** @@ -265,7 +287,7 @@ private function askQuestion( $option, $validateInline = false ) { - if (get_class($option) === 'Magento\Framework\Setup\Option\SelectConfigOption') { + if ($option instanceof \Magento\Framework\Setup\Option\SelectConfigOption) { if ($option->isValueRequired()) { $question = new ChoiceQuestion( $option->getDescription() . '? ', @@ -291,16 +313,20 @@ private function askQuestion( $option->getDefault() ); } - } $question->setValidator(function ($answer) use ($option, $validateInline) { - $answer = trim($answer); - if (get_class($option) === 'Magento\Framework\Setup\Option\SelectConfigOption') { + if ($option instanceof \Magento\Framework\Setup\Option\SelectConfigOption) { $answer = $option->getSelectOptions()[$answer]; } + if ($answer == null) { + $answer = ''; + } else { + $answer = trim($answer); + } + if ($validateInline) { $option->validate($answer); } @@ -312,4 +338,4 @@ private function askQuestion( return $value; } -} \ No newline at end of file +}