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

Breadcrumb

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

function Question::setAutocompleterValues

Sets values for the autocompleter.

Return value

$this

Throws

LogicException

1 call to Question::setAutocompleterValues()
ChoiceQuestion::__construct in vendor/symfony/console/Question/ChoiceQuestion.php

File

vendor/symfony/console/Question/Question.php, line 142

Class

Question
Represents a Question.

Namespace

Symfony\Component\Console\Question

Code

public function setAutocompleterValues(?iterable $values) : static {
    if (\is_array($values)) {
        $values = $this->isAssoc($values) ? array_merge(array_keys($values), array_values($values)) : array_values($values);
        $callback = static fn() => $values;
    }
    elseif ($values instanceof \Traversable) {
        $callback = static function () use ($values) {
            static $valueCache;
            return $valueCache ??= iterator_to_array($values, false);
        };
    }
    else {
        $callback = null;
    }
    return $this->setAutocompleterCallback($callback);
}
RSS feed
Powered by Drupal