public function MessageNotifyUiSenderMailSettingsForm::submit in Message UI 8
Implementing logic for sender which relate to the plugin.
Each plugin of this type provide UI for a notifier plugin. After the form is submitted this function will be invoked.
Parameters
\Drupal\message_notify\MessageNotifier $notifier: The notifier which the plugin take care.
\Drupal\Core\Form\FormStateInterface $formState: The form state object.
Overrides MessageNotifyUiSenderSettingsFormInterface::submit
File
- modules/
message_notify_ui/ src/ Plugin/ MessageNotifyUiSenderSettingsForm/ MessageNotifyUiSenderMailSettingsForm.php, line 56
Class
- MessageNotifyUiSenderMailSettingsForm
- Message notify plugin form for email.
Namespace
Drupal\message_notify_ui\Plugin\MessageNotifyUiSenderSettingsFormCode
public function submit(MessageNotifier $notifier, FormStateInterface $formState) {
$settings = [];
if ($formState
->getValue('use_custom')) {
$settings['mail'] = $formState
->getValue('email');
}
if ($formState
->getValue('language')) {
$settings['language override'] = $formState
->getValue($formState
->getValue('language'));
}
if ($notifier
->send($this
->getMessage(), $settings, 'email')) {
\Drupal::messenger()
->addMessage(t('The email sent successfully.'));
}
}