Skip to content

Commit

Permalink
ADDED user and adminUser questions
Browse files Browse the repository at this point in the history
Code cleanup
  • Loading branch information
Denis Ristic committed Oct 13, 2017
1 parent 720496c commit 0e4dd85
Showing 1 changed file with 50 additions and 16 deletions.
66 changes: 50 additions & 16 deletions setup/src/Magento/Setup/Console/Command/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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;
}
}
}

0 comments on commit 0e4dd85

Please sign in to comment.