You are here

protected function EmailConfirmerResponseForm::skipConfirmationForm in Email confirmer 8

Skip the response form and positively confirm the confirmation.

Parameters

\Drupal\Core\Form\FormStateInterface $form_state: The form state.

Return value

\Symfony\Component\HttpFoundation\RedirectResponse Redirection response according to the confirmation result.

1 call to EmailConfirmerResponseForm::skipConfirmationForm()
EmailConfirmerResponseForm::buildForm in src/Form/EmailConfirmerResponseForm.php
Form constructor.

File

src/Form/EmailConfirmerResponseForm.php, line 233

Class

EmailConfirmerResponseForm
Email confirmation response form.

Namespace

Drupal\email_confirmer\Form

Code

protected function skipConfirmationForm(FormStateInterface $form_state) {
  try {
    $this
      ->confirmConfirmation($form_state);
  } catch (InvalidConfirmationStateException $exception) {
    $this
      ->confirmationError($form_state);
  }

  // Use RedirectResponse because redirecting with form state is not working
  // inside buildForm.
  $redirect_state = $form_state
    ->getRedirect() ?: $this
    ->getRedirectUrl('error');
  if ($redirect_state instanceof RedirectResponse) {
    $redirect_response = $redirect_state;
  }
  else {
    $redirect_response = new RedirectResponse($redirect_state instanceof Url ? $redirect_state
      ->setAbsolute()
      ->toString() : $redirect_state);
  }
  return $redirect_response;
}