You are here

public function QuestionHelper::ask in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/console/Helper/QuestionHelper.php \Symfony\Component\Console\Helper\QuestionHelper::ask()

Asks a question to the user.

Parameters

InputInterface $input An InputInterface instance:

OutputInterface $output An OutputInterface instance:

Question $question The question to ask:

Return value

string The user answer

Throws

\RuntimeException If there is no data to read in the input stream

1 call to QuestionHelper::ask()
SymfonyQuestionHelper::ask in vendor/symfony/console/Helper/SymfonyQuestionHelper.php
Asks a question to the user.
1 method overrides QuestionHelper::ask()
SymfonyQuestionHelper::ask in vendor/symfony/console/Helper/SymfonyQuestionHelper.php
Asks a question to the user.

File

vendor/symfony/console/Helper/QuestionHelper.php, line 43

Class

QuestionHelper
The QuestionHelper class provides helpers to interact with the user.

Namespace

Symfony\Component\Console\Helper

Code

public function ask(InputInterface $input, OutputInterface $output, Question $question) {
  if ($output instanceof ConsoleOutputInterface) {
    $output = $output
      ->getErrorOutput();
  }
  if (!$input
    ->isInteractive()) {
    return $question
      ->getDefault();
  }
  if (!$question
    ->getValidator()) {
    return $this
      ->doAsk($output, $question);
  }
  $that = $this;
  $interviewer = function () use ($output, $question, $that) {
    return $that
      ->doAsk($output, $question);
  };
  return $this
    ->validateAttempts($interviewer, $output, $question);
}