From 0e4dd85af64b5d9ed035da373e80d6d3fb08e1f8 Mon Sep 17 00:00:00 2001 From: Denis Ristic Date: Fri, 13 Oct 2017 13:22:45 +0200 Subject: [PATCH] ADDED user and adminUser questions Code cleanup --- .../Setup/Console/Command/InstallCommand.php | 66 ++++++++++++++----- 1 file changed, 50 insertions(+), 16 deletions(-) diff --git a/setup/src/Magento/Setup/Console/Command/InstallCommand.php b/setup/src/Magento/Setup/Console/Command/InstallCommand.php index 98423c26d39e2..467e94febef39 100644 --- a/setup/src/Magento/Setup/Console/Command/InstallCommand.php +++ b/setup/src/Magento/Setup/Console/Command/InstallCommand.php @@ -215,13 +215,33 @@ private function interactiveQuestions(InputInterface $input, OutputInterface $ou { $helper = $this->getHelper('question'); $configOptionsToValidate = []; + foreach ($this->configModel->getAvailableOptions() as $option) { + $configOptionsToValidate[$option->getName()] = $this->askQuestion( + $input, + $output, + $helper, + $option, + true + ); + } - $configOptionsToValidate[$option->getName()] = $this->askQuestion($input, $output, $helper, $option); + foreach ($this->userConfig->getOptionsList() as $option) { + $configOptionsToValidate[$option->getName()] = $this->askQuestion( + $input, + $output, + $helper, + $option + ); + } - /*$question = new Question($option->getDescription() . '? ', $option->getDefault()); - $configOptionsToValidate[$option->getName()] = $helper->ask($input, $output, $question); - */ + foreach ($this->adminUser->getOptionsList() as $option) { + $configOptionsToValidate[$option->getName()] = $this->askQuestion( + $input, + $output, + $helper, + $option + ); } return $configOptionsToValidate; } @@ -234,11 +254,17 @@ private function interactiveQuestions(InputInterface $input, OutputInterface $ou * @param InputInterface $input * @param OutputInterface $output * @param QuestionHelper $helper - * @param Magento\Framework\Setup\Option\TextConfigOption|Magento\Framework\Setup\Option\FlagConfigOption\Magento\Framework\Setup\Option\SelectConfigOption $option + * @param TextConfigOption|FlagConfigOption\SelectConfigOption $option + * @param Boolean $validateInline * @return string[] Array of inputs */ - private function askQuestion(InputInterface $input, OutputInterface $output, QuestionHelper $helper, $option) - { + private function askQuestion( + InputInterface $input, + OutputInterface $output, + QuestionHelper $helper, + $option, + $validateInline = false + ) { if (get_class($option) === 'Magento\Framework\Setup\Option\SelectConfigOption') { if ($option->isValueRequired()) { $question = new ChoiceQuestion( @@ -253,10 +279,6 @@ private function askQuestion(InputInterface $input, OutputInterface $output, Que $option->getDefault() ); } - $question->setValidator(function ($answer) use ($option) { - $option->validate($option->getSelectOptions()[$answer]); - return $answer; - }); } else { if ($option->isValueRequired()) { $question = new Question( @@ -269,13 +291,25 @@ private function askQuestion(InputInterface $input, OutputInterface $output, Que $option->getDefault() ); } - $question->setValidator(function ($answer) use ($option) { - $option->validate($answer); - return $answer; - }); + } + $question->setValidator(function ($answer) use ($option, $validateInline) { + $answer = trim($answer); + + if (get_class($option) === 'Magento\Framework\Setup\Option\SelectConfigOption') { + $answer = $option->getSelectOptions()[$answer]; + } + + if ($validateInline) { + $option->validate($answer); + } + + return $answer; + }); + $value = $helper->ask($input, $output, $question); + return $value; } -} +} \ No newline at end of file