public function CommentNotifyUnsubscribe::submitForm in Comment Notify 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/ CommentNotifyUnsubscribe.php, line 70
Class
- CommentNotifyUnsubscribe
- Unsubscribe form for Comment Notify.
Namespace
Drupal\comment_notify\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
module_load_include('inc', 'comment_notify', 'comment_notify');
$email = trim($form_state
->getValue([
'email',
]));
$comments = comment_notify_unsubscribe_by_email($email);
// Update the admin about the state of the subscription.
if ($comments == 0) {
$this->messenger
->addWarning($this
->t("There were no active comment notifications for that email."));
}
else {
$this->messenger
->addStatus($this
->t("Email unsubscribed from all the comment notifications."));
}
}