class WebformAdminConfigHandlersForm in Webform 8.5
Same name and namespace in other branches
- 6.x src/Form/AdminConfig/WebformAdminConfigHandlersForm.php \Drupal\webform\Form\AdminConfig\WebformAdminConfigHandlersForm
Configure webform admin settings for handlers.
Hierarchy
- class \Drupal\Core\Form\FormBase implements ContainerInjectionInterface, FormInterface uses DependencySerializationTrait, LoggerChannelTrait, MessengerTrait, LinkGeneratorTrait, RedirectDestinationTrait, UrlGeneratorTrait, StringTranslationTrait
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
- class \Drupal\webform\Form\AdminConfig\WebformAdminConfigBaseForm
- class \Drupal\webform\Form\AdminConfig\WebformAdminConfigHandlersForm
- class \Drupal\webform\Form\AdminConfig\WebformAdminConfigBaseForm
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
Expanded class hierarchy of WebformAdminConfigHandlersForm
1 string reference to 'WebformAdminConfigHandlersForm'
File
- src/
Form/ AdminConfig/ WebformAdminConfigHandlersForm.php, line 15
Namespace
Drupal\webform\Form\AdminConfigView source
class WebformAdminConfigHandlersForm extends WebformAdminConfigBaseForm {
/**
* The module handler.
*
* @var \Drupal\Core\Extension\ModuleHandlerInterface
*/
protected $moduleHandler;
/**
* The webform token manager.
*
* @var \Drupal\webform\WebformTokenManagerInterface
*/
protected $tokenManager;
/**
* The webform handler manager.
*
* @var \Drupal\webform\Plugin\WebformHandlerManagerInterface
*/
protected $handlerManager;
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'webform_admin_config_handlers_form';
}
/**
* Constructs a WebformAdminConfigHandlersForm object.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The factory for configuration objects.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
* @param \Drupal\webform\WebformTokenManagerInterface $token_manager
* The webform token manager.
* @param \Drupal\webform\Plugin\WebformHandlerManagerInterface $handler_manager
* The webform handler manager.
*/
public function __construct(ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler, WebformTokenManagerInterface $token_manager, WebformHandlerManagerInterface $handler_manager) {
parent::__construct($config_factory);
$this->moduleHandler = $module_handler;
$this->tokenManager = $token_manager;
$this->handlerManager = $handler_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('config.factory'), $container
->get('module_handler'), $container
->get('webform.token_manager'), $container
->get('plugin.manager.webform.handler'));
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('webform.settings');
// Email / Handler: Mail.
$form['mail'] = [
'#type' => 'details',
'#title' => $this
->t('Email settings'),
'#open' => TRUE,
'#tree' => TRUE,
];
$form['mail']['roles'] = [
'#type' => 'webform_roles',
'#title' => $this
->t('Recipient user roles'),
'#description' => $this
->t("Select user roles that can be assigned to receive a webform's email. <em>Please note: Selected user roles will be available to all webforms.</em>"),
'#include_anonymous' => FALSE,
'#default_value' => $config
->get('mail.roles'),
];
$form['mail']['default_to_mail'] = [
'#type' => 'textfield',
'#title' => $this
->t('Default to email'),
'#description' => $this
->t('The default recipient address for emailed webform results.'),
'#required' => TRUE,
'#default_value' => $config
->get('mail.default_to_mail'),
];
$form['mail']['default_from_mail'] = [
'#type' => 'textfield',
'#title' => $this
->t('Default from email'),
'#description' => $this
->t('The default sender address for emailed webform results; often the email address of the maintainer of your forms.'),
'#required' => TRUE,
'#default_value' => $config
->get('mail.default_from_mail'),
];
$form['mail']['default_from_name'] = [
'#type' => 'textfield',
'#title' => $this
->t('Default from name'),
'#description' => $this
->t('The default sender name which is used along with the default from address.'),
'#required' => TRUE,
'#default_value' => $config
->get('mail.default_from_name'),
];
$form['mail']['default_reply_to'] = [
'#type' => 'textfield',
'#title' => $this
->t('Default reply-to email'),
'#description' => $this
->t("The default email address that a recipient will see when they are replying to an email. Leave blank to automatically use the 'From email' address. Setting the 'Reply-to' to the 'From email' prevent emails from being flagged as spam."),
'#default_value' => $config
->get('mail.default_reply_to'),
];
$form['mail']['default_return_path'] = [
'#type' => 'textfield',
'#title' => $this
->t('Default return path (email)'),
'#description' => $this
->t("The default email address to which bounce messages are delivered. Leave blank to automatically use the 'From email' address."),
'#default_value' => $config
->get('mail.default_return_path'),
];
$form['mail']['default_sender_mail'] = [
'#type' => 'textfield',
'#title' => $this
->t('Default sender email'),
'#description' => $this
->t('The default sender address for emailed webform results; often the email address of the maintainer of your forms. The person or agent submitting the message to the network, if other than shown by the From header'),
'#default_value' => $config
->get('mail.default_sender_mail'),
];
$form['mail']['default_sender_name'] = [
'#type' => 'textfield',
'#title' => $this
->t('Default sender name'),
'#description' => $this
->t('The default sender name which is used along with the default sender email address.'),
'#default_value' => $config
->get('mail.default_sender_name'),
];
$form['mail']['default_subject'] = [
'#type' => 'textfield',
'#title' => $this
->t('Default email subject'),
'#required' => TRUE,
'#maxlength' => NULL,
'#default_value' => $config
->get('mail.default_subject'),
];
$form['mail']['default_body_text'] = [
'#type' => 'webform_codemirror',
'#mode' => 'text',
'#title' => $this
->t('Default email body (Plain text)'),
'#required' => TRUE,
'#default_value' => $config
->get('mail.default_body_text'),
];
$form['mail']['default_body_html'] = [
'#type' => 'webform_codemirror',
'#mode' => 'html',
'#title' => $this
->t('Default email body (HTML)'),
'#required' => TRUE,
'#default_value' => $config
->get('mail.default_body_html'),
];
$form['mail']['token_tree_link'] = $this->tokenManager
->buildTreeElement();
// Email / Handler: Types.
$form['handler_types'] = [
'#type' => 'details',
'#title' => $this
->t('Submission handlers'),
'#description' => $this
->t('Select available submission handlers'),
'#open' => TRUE,
'#weight' => 10,
];
$form['handler_types']['excluded_handlers'] = $this
->buildExcludedPlugins($this->handlerManager, $config
->get('handler.excluded_handlers'));
$excluded_handler_checkboxes = [];
foreach ($form['handler_types']['excluded_handlers']['#options'] as $handler_id => $option) {
if ($excluded_handler_checkboxes) {
$excluded_handler_checkboxes[] = 'or';
}
$excluded_handler_checkboxes[] = [
':input[name="excluded_handlers[' . $handler_id . ']"]' => [
'checked' => FALSE,
],
];
}
$form['handler_types']['excluded_handlers_message'] = [
'#type' => 'webform_message',
'#message_message' => $this
->t('All excluded handlers must be manually removed from existing webforms.'),
'#message_type' => 'warning',
'#states' => [
'visible' => $excluded_handler_checkboxes,
],
];
$this->tokenManager
->elementValidate($form);
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$excluded_handlers = $this
->convertIncludedToExcludedPluginIds($this->handlerManager, $form_state
->getValue('excluded_handlers'));
// Update config and submit form.
$config = $this
->config('webform.settings');
$config
->set('handler', [
'excluded_handlers' => $excluded_handlers,
]);
$config
->set('mail', $form_state
->getValue('mail'));
parent::submitForm($form, $form_state);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigFormBaseTrait:: |
protected | function | Retrieves a configuration object. | |
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
FormBase:: |
protected | property | The config factory. | 1 |
FormBase:: |
protected | property | The request stack. | 1 |
FormBase:: |
protected | property | The route match. | |
FormBase:: |
protected | function | Gets the config factory for this form. | 1 |
FormBase:: |
private | function | Returns the service container. | |
FormBase:: |
protected | function | Gets the current user. | |
FormBase:: |
protected | function | Gets the request object. | |
FormBase:: |
protected | function | Gets the route match. | |
FormBase:: |
protected | function | Gets the logger for a specific channel. | |
FormBase:: |
protected | function |
Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait:: |
|
FormBase:: |
public | function | Resets the configuration factory. | |
FormBase:: |
public | function | Sets the config factory for this form. | |
FormBase:: |
public | function | Sets the request stack object to use. | |
FormBase:: |
public | function |
Form validation handler. Overrides FormInterface:: |
62 |
LinkGeneratorTrait:: |
protected | property | The link generator. | 1 |
LinkGeneratorTrait:: |
protected | function | Returns the link generator. | |
LinkGeneratorTrait:: |
protected | function | Renders a link to a route given a route name and its parameters. | |
LinkGeneratorTrait:: |
public | function | Sets the link generator service. | |
LoggerChannelTrait:: |
protected | property | The logger channel factory service. | |
LoggerChannelTrait:: |
protected | function | Gets the logger for a specific channel. | |
LoggerChannelTrait:: |
public | function | Injects the logger channel factory. | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
RedirectDestinationTrait:: |
protected | property | The redirect destination service. | 1 |
RedirectDestinationTrait:: |
protected | function | Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url. | |
RedirectDestinationTrait:: |
protected | function | Returns the redirect destination service. | |
RedirectDestinationTrait:: |
public | function | Sets the redirect destination service. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
UrlGeneratorTrait:: |
protected | property | The url generator. | |
UrlGeneratorTrait:: |
protected | function | Returns the URL generator service. | |
UrlGeneratorTrait:: |
public | function | Sets the URL generator service. | |
UrlGeneratorTrait:: |
protected | function | Generates a URL or path for a specific route based on the given parameters. | |
WebformAdminConfigBaseForm:: |
protected | function | Build bulk operation settings for webforms and submissions. | |
WebformAdminConfigBaseForm:: |
protected | function | Build excluded plugins element. | |
WebformAdminConfigBaseForm:: |
protected | function | Convert included ids returned from table select element to excluded ids. | |
WebformAdminConfigBaseForm:: |
protected | function |
Gets the configuration names that will be editable. Overrides ConfigFormBaseTrait:: |
|
WebformAdminConfigBaseForm:: |
protected | function | Get plugin definitions. | |
WebformAdminConfigBaseForm:: |
public static | function | Form API callback. Validate bulk form actions. | |
WebformAdminConfigHandlersForm:: |
protected | property | The webform handler manager. | |
WebformAdminConfigHandlersForm:: |
protected | property | The module handler. | |
WebformAdminConfigHandlersForm:: |
protected | property | The webform token manager. | |
WebformAdminConfigHandlersForm:: |
public | function |
Form constructor. Overrides ConfigFormBase:: |
|
WebformAdminConfigHandlersForm:: |
public static | function |
Instantiates a new instance of this class. Overrides ConfigFormBase:: |
|
WebformAdminConfigHandlersForm:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
WebformAdminConfigHandlersForm:: |
public | function |
Form submission handler. Overrides WebformAdminConfigBaseForm:: |
|
WebformAdminConfigHandlersForm:: |
public | function |
Constructs a WebformAdminConfigHandlersForm object. Overrides ConfigFormBase:: |