public function DialogHelper::askConfirmation in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/console/Helper/DialogHelper.php \Symfony\Component\Console\Helper\DialogHelper::askConfirmation()
Asks a confirmation to the user.
The question will be asked until the user answers by nothing, yes, or no.
Parameters
OutputInterface $output An Output instance:
string|array $question The question to ask:
bool $default The default answer if the user enters nothing:
Return value
bool true if the user has confirmed, false otherwise
File
- vendor/
symfony/ console/ Helper/ DialogHelper.php, line 245
Class
- DialogHelper
- The Dialog class provides helpers to interact with the user.
Namespace
Symfony\Component\Console\HelperCode
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]);
}