public function SubscriberValidateForm::submitForm in Simplenews 3.x
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/ SubscriberValidateForm.php, line 94
Class
- SubscriberValidateForm
- Do a mass subscription for a list of email addresses.
Namespace
Drupal\simplenews\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$mail = trim($form_state
->getValue('mail'));
if (($subscriber = Subscriber::loadByMail($mail)) && $subscriber
->getStatus()) {
$params['from'] = $this->mailer
->getFrom();
$params['context']['simplenews_subscriber'] = $subscriber;
$this->mailManager
->mail('simplenews', 'validate', $subscriber
->getMail(), $subscriber
->getLangcode(), $params, $params['from']['address']);
}
$this
->messenger()
->addStatus($this
->t('If %mail is subscribed, an email will be sent with a link to manage your subscriptions.', [
'%mail' => $mail,
]));
$form_state
->setRedirect('<front>');
}