You are here

protected function QuestionHelper::writePrompt 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::writePrompt()

Outputs the question prompt.

Parameters

OutputInterface $output:

Question $question:

1 call to QuestionHelper::writePrompt()
QuestionHelper::doAsk in vendor/symfony/console/Helper/QuestionHelper.php
Asks the question to the user.
1 method overrides QuestionHelper::writePrompt()
SymfonyQuestionHelper::writePrompt in vendor/symfony/console/Helper/SymfonyQuestionHelper.php
Outputs the question prompt.

File

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

Class

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

Namespace

Symfony\Component\Console\Helper

Code

protected function writePrompt(OutputInterface $output, Question $question) {
  $message = $question
    ->getQuestion();
  if ($question instanceof ChoiceQuestion) {
    $width = max(array_map('strlen', array_keys($question
      ->getChoices())));
    $messages = (array) $question
      ->getQuestion();
    foreach ($question
      ->getChoices() as $key => $value) {
      $messages[] = sprintf("  [<info>%-{$width}s</info>] %s", $key, $value);
    }
    $output
      ->writeln($messages);
    $message = $question
      ->getPrompt();
  }
  $output
    ->write($message);
}