You are here

protected function EmailConfirmerResponseForm::confirmConfirmation in Email confirmer 8

Confirms the email confirmation.

Parameters

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

Throws

\Drupal\email_confirmer\InvalidConfirmationStateException If confirmation is cancelled, expired or already confirmed.

2 calls to EmailConfirmerResponseForm::confirmConfirmation()
EmailConfirmerResponseForm::skipConfirmationForm in src/Form/EmailConfirmerResponseForm.php
Skip the response form and positively confirm the confirmation.
EmailConfirmerResponseForm::submitForm in src/Form/EmailConfirmerResponseForm.php
This is the default entity object builder function. It is called before any other submit handler to build the new entity object to be used by the following submit handlers. At this point of the form workflow the entity is validated and the form state…

File

src/Form/EmailConfirmerResponseForm.php, line 174

Class

EmailConfirmerResponseForm
Email confirmation response form.

Namespace

Drupal\email_confirmer\Form

Code

protected function confirmConfirmation(FormStateInterface $form_state) {

  /** @var \Drupal\email_confirmer\EmailConfirmationInterface $confirmation */
  $confirmation = $this
    ->getEntity();
  if (!$confirmation
    ->confirm($this
    ->getRouteMatch()
    ->getParameter('hash'))) {
    $this
      ->confirmationError($form_state);
    return;
  }
  $this
    ->messenger()
    ->addStatus($this
    ->t('Email confirmation confirmed.'));
  $confirmation
    ->save();
  $form_state
    ->setRedirectUrl($this
    ->getRedirectUrl('confirm'));
}