You are here

public function UserEmailVerificationRequestForm::submitForm in User email verification 8

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

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

Overrides FormInterface::submitForm

File

src/Form/UserEmailVerificationRequestForm.php, line 164

Class

UserEmailVerificationRequestForm
Class UserEmailVerificationRequestForm.

Namespace

Drupal\user_email_verification\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $uid = trim($form_state
    ->getValue('uid', 0));
  if ($uid) {
    $this->userEmailVerification
      ->sendVerifyMailById($uid);
    $this
      ->messenger()
      ->addStatus($this
      ->t('Further instructions have been sent to the Email address of a requested user.'));
    if ($this->currentUser
      ->isAuthenticated()) {
      $form_state
        ->setRedirect('entity.user.canonical', [
        'user' => $uid,
      ]);
    }
    else {
      $form_state
        ->setRedirect('<front>');
    }
  }
}