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

Breadcrumb

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

function QuestionHelper::validateAttempts

Validates an attempt.

Parameters

callable $interviewer A callable that will ask for a question and return the result:

Throws

\Exception In case the max number of attempts has been reached and no valid response has been given

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

File

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

Class

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

Namespace

Symfony\Component\Console\Helper

Code

private function validateAttempts(callable $interviewer, OutputInterface $output, Question $question) : mixed {
    $error = null;
    $attempts = $question->getMaxAttempts();
    while (null === $attempts || $attempts--) {
        if (null !== $error) {
            $this->writeError($output, $error);
        }
        try {
            return $question->getValidator()($interviewer());
        } catch (RuntimeException $e) {
            throw $e;
        } catch (\Exception $error) {
        }
    }
    throw $error;
}

API Navigation

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