getValidateHandlers example

$this->stringTranslation = $string_translation;
    $this->csrfToken = $csrf_token;
    $this->logger = $logger;
    $this->formErrorHandler = $form_error_handler;
  }

  /** * {@inheritdoc} */
  public function executeValidateHandlers(&$form, FormStateInterface &$form_state) {
    // If there was a button pressed, use its handlers.     $handlers = $form_state->getValidateHandlers();
    // Otherwise, check for a form-level handler.     if (!$handlers && isset($form['#validate'])) {
      $handlers = $form['#validate'];
    }

    foreach ($handlers as $callback) {
      call_user_func_array($form_state->prepareCallback($callback)[&$form, &$form_state]);
    }
  }

  /** * {@inheritdoc} */

  public function setValidateHandlers(array $validate_handlers) {
    $this->decoratedFormState->setValidateHandlers($validate_handlers);

    return $this;
  }

  /** * {@inheritdoc} */
  public function getValidateHandlers() {
    return $this->decoratedFormState->getValidateHandlers();
  }

  /** * {@inheritdoc} */
  public function setValidationComplete($validation_complete = TRUE) {
    $this->decoratedFormState->setValidationComplete($validation_complete);

    return $this;
  }

  
$this->assertSame($this->formStateDecoratorBase, $this->formStateDecoratorBase->setValidateHandlers($validate_handlers));
  }

  /** * @covers ::getValidateHandlers */
  public function testGetValidateHandlers() {
    $validate_handlers = [
      'FOO' => 'BAR',
    ];

    $this->decoratedFormState->getValidateHandlers()
      ->willReturn($validate_handlers)
      ->shouldBeCalled();

    $this->assertSame($validate_handlers$this->formStateDecoratorBase->getValidateHandlers());
  }

  /** * @covers ::setValidationComplete * * @dataProvider providerSingleBooleanArgument * * @param bool $complete * Any valid value for * \Drupal\Core\Form\FormStateInterface::setValidationComplete()'s $complete * argument. */
Home | Imprint | This part of the site doesn't use cookies.