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

Breadcrumb

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

function ConfirmationQuestion::getDefaultNormalizer

Returns the default answer normalizer.

1 call to ConfirmationQuestion::getDefaultNormalizer()
ConfirmationQuestion::__construct in vendor/symfony/console/Question/ConfirmationQuestion.php

File

vendor/symfony/console/Question/ConfirmationQuestion.php, line 39

Class

ConfirmationQuestion
Represents a yes/no question.

Namespace

Symfony\Component\Console\Question

Code

private function getDefaultNormalizer() : callable {
    $default = $this->getDefault();
    $regex = $this->trueAnswerRegex;
    return function ($answer) use ($default, $regex) {
        if (\is_bool($answer)) {
            return $answer;
        }
        $answerIsTrue = (bool) preg_match($regex, $answer);
        if (false === $default) {
            return $answer && $answerIsTrue;
        }
        return '' === $answer || $answerIsTrue;
    };
}

API Navigation

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