Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. QuestionHelper.php

function QuestionHelper::formatChoiceQuestionChoices

Return value

string[]

2 calls to QuestionHelper::formatChoiceQuestionChoices()
QuestionHelper::writePrompt in vendor/symfony/console/Helper/QuestionHelper.php
Outputs the question prompt.
SymfonyQuestionHelper::writePrompt in vendor/symfony/console/Helper/SymfonyQuestionHelper.php
Outputs the question prompt.

File

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

Class

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

Namespace

Symfony\Component\Console\Helper

Code

protected function formatChoiceQuestionChoices(ChoiceQuestion $question, string $tag) : array {
    $messages = [];
    $maxWidth = max(array_map([
        __CLASS__,
        'width',
    ], array_keys($choices = $question->getChoices())));
    foreach ($choices as $key => $value) {
        $padding = str_repeat(' ', $maxWidth - self::width($key));
        $messages[] = \sprintf("  [<{$tag}>%s{$padding}</{$tag}>] %s", $key, $value);
    }
    return $messages;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal