class MessageNotifyUiSenderMailSettingsForm in Message UI 8
Message notify plugin form for email.
Plugin annotation
@MessageNotifyUiSenderSettingsForm(
id = "message_notify_ui_sender_settings_form",
label = @Translation("The plugin ID."),
notify_plugin = "email"
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\message_notify_ui\MessageNotifyUiSenderSettingsFormBase implements MessageNotifyUiSenderSettingsFormInterface
- class \Drupal\message_notify_ui\Plugin\MessageNotifyUiSenderSettingsForm\MessageNotifyUiSenderMailSettingsForm implements MessageNotifyUiSenderSettingsFormInterface
- class \Drupal\message_notify_ui\MessageNotifyUiSenderSettingsFormBase implements MessageNotifyUiSenderSettingsFormInterface
Expanded class hierarchy of MessageNotifyUiSenderMailSettingsForm
File
- modules/
message_notify_ui/ src/ Plugin/ MessageNotifyUiSenderSettingsForm/ MessageNotifyUiSenderMailSettingsForm.php, line 19
Namespace
Drupal\message_notify_ui\Plugin\MessageNotifyUiSenderSettingsFormView source
class MessageNotifyUiSenderMailSettingsForm extends MessageNotifyUiSenderSettingsFormBase implements MessageNotifyUiSenderSettingsFormInterface {
/**
* {@inheritdoc}
*/
public function form() {
return [
'use_custom' => [
'#type' => 'checkbox',
'#title' => t('Use custom email'),
'#description' => t('Use the message owner message'),
],
'email' => [
'#type' => 'email',
'#title' => t('Email address'),
'#description' => t('The email address'),
'#states' => [
'visible' => [
':input[name="use_custom"]' => [
'checked' => TRUE,
],
],
],
],
];
}
/**
* {@inheritdoc}
*/
public function validate(array $form, FormStateInterface $formState) {
if ($formState
->getValue('use_custom') && !$formState
->getValue('email')) {
$formState
->setErrorByName('email', t('The email field cannot be empty.'));
}
}
/**
* {@inheritdoc}
*/
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.'));
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MessageNotifyUiSenderMailSettingsForm:: |
public | function |
The form settings for the plugin. Overrides MessageNotifyUiSenderSettingsFormInterface:: |
|
MessageNotifyUiSenderMailSettingsForm:: |
public | function |
Implementing logic for sender which relate to the plugin. Overrides MessageNotifyUiSenderSettingsFormInterface:: |
|
MessageNotifyUiSenderMailSettingsForm:: |
public | function |
Validating the form. Overrides MessageNotifyUiSenderSettingsFormBase:: |
|
MessageNotifyUiSenderSettingsFormBase:: |
protected | property | The form settings. | |
MessageNotifyUiSenderSettingsFormBase:: |
protected | property | The form state interface. | |
MessageNotifyUiSenderSettingsFormBase:: |
protected | property | The message object. | |
MessageNotifyUiSenderSettingsFormBase:: |
public | function | Get the form API element. | |
MessageNotifyUiSenderSettingsFormBase:: |
public | function | Return the form state object. | |
MessageNotifyUiSenderSettingsFormBase:: |
public | function | Get the message object. | |
MessageNotifyUiSenderSettingsFormBase:: |
public | function | Setter for the form variable. | |
MessageNotifyUiSenderSettingsFormBase:: |
public | function | Set the form state. | |
MessageNotifyUiSenderSettingsFormBase:: |
public | function | Set the message object. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
PluginBase:: |
public | function | Constructs a \Drupal\Component\Plugin\PluginBase object. | 92 |