public askConfirmation ( Symfony\Component\Console\Output\OutputInterface $output, string | array $question, boolean $default = true ) : boolean | ||
$output | Symfony\Component\Console\Output\OutputInterface | |
$question | string | array | The question to ask |
$default | boolean | The default answer if the user enters nothing |
return | boolean | true if the user has confirmed, false otherwise |
public function askConfirmation(OutputInterface $output, $question, $default = true)
{
$answer = 'z';
while ($answer && !in_array(strtolower($answer[0]), array('y', 'n'))) {
$answer = $this->ask($output, $question);
}
if (false === $default) {
return $answer && 'y' == strtolower($answer[0]);
}
return !$answer || 'y' == strtolower($answer[0]);
}
/** * Asks user what the path to Php source is. */ public function configure() { $default = $this->settings->getDefaultValueFor('enablePhpTools', true); $this->settings['enablePhpTools'] = $this->dialog->askConfirmation($this->output, "\nDo you want to install the QA tools for PHP?", $default); if ($this->settings['enablePhpTools']) { $this->output->writeln("\n<info>Configuring PHP inspections</info>\n"); } }