You are here

public function UsermailDebuggerForm::submitForm in Mail Debugger 8

Submit Form Handler.

Overrides FormInterface::submitForm

File

src/Form/UsermailDebuggerForm.php, line 142

Class

UsermailDebuggerForm
Class UsermailDebuggerForm.

Namespace

Drupal\mail_debugger\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $this->defaultsStorage
    ->set('user', $form_state
    ->getValue('user'));
  $this->defaultsStorage
    ->set('operation', $form_state
    ->getValue('operation'));

  /** @var \Drupal\user\Entity\User $user */
  $user = $this->userStorage
    ->load($form_state
    ->getValue('user'));
  $result = _user_mail_notify($form_state
    ->getValue('operation'), $user);
  if ($result) {
    $this
      ->messenger()
      ->addStatus($this
      ->t("Sent a message to :mail.", [
      ':mail' => $user
        ->getEmail(),
    ]));
  }
}