You are here

public function EmailConfirmerController::resendConfirmation in Email confirmer 8

Resend confirmation email.

Parameters

\Drupal\email_confirmer\EmailConfirmationInterface $confirmation: The confirmation entity.

1 string reference to 'EmailConfirmerController::resendConfirmation'
email_confirmer.routing.yml in ./email_confirmer.routing.yml
email_confirmer.routing.yml

File

src/Controller/EmailConfirmerController.php, line 19

Class

EmailConfirmerController
Returns responses for email confirmer module routes.

Namespace

Drupal\email_confirmer\Controller

Code

public function resendConfirmation(EmailConfirmationInterface $confirmation) {
  try {
    if ($confirmation
      ->sendRequest()) {

      // Send timestamp was updated, save it.
      $confirmation
        ->save();
      $this
        ->messenger()
        ->addStatus($this
        ->t('A new confirmation message has been sent to %mail', [
        '%mail' => $confirmation
          ->getEmail(),
      ]));
    }
    else {
      $this
        ->messenger()
        ->addError($this
        ->t('Unable to send email. Contact the site administrator if the problem persists.'));
    }
  } catch (\Exception $e) {
    $this
      ->messenger()
      ->addError($this
      ->t('This email confirmation is no longer valid.'));
  }
  return $this
    ->redirect('<front>');
}