Skip to content

Commit

Permalink
ADDED re-run command output
Browse files Browse the repository at this point in the history
FIXED phpcs validation
  • Loading branch information
Denis Ristic committed Oct 13, 2017
1 parent 0e4dd85 commit ce12a74
Showing 1 changed file with 32 additions and 6 deletions.
38 changes: 32 additions & 6 deletions setup/src/Magento/Setup/Console/Command/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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("<comment>Try re-running command: php bin/magento setup:install{$command}</comment>");
}

$errors = $this->configModel->validate($configOptionsToValidate);
$errors = array_merge($errors, $this->adminUser->validate($input));
$errors = array_merge($errors, $this->validate($input));
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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;
}

/**
Expand All @@ -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() . '? ',
Expand All @@ -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);
}
Expand All @@ -312,4 +338,4 @@ private function askQuestion(

return $value;
}
}
}

0 comments on commit ce12a74

Please sign in to comment.