class AdminSettingsForm in Mass Contact 8
Admin settings form for Mass Contact.
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\mass_contact\Form\SettingsFormBase
- class \Drupal\mass_contact\Form\AdminSettingsForm
- class \Drupal\mass_contact\Form\SettingsFormBase
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
Expanded class hierarchy of AdminSettingsForm
1 file declares its use of AdminSettingsForm
- AdminSettingsFormTest.php in src/
Tests/ Form/ AdminSettingsFormTest.php
1 string reference to 'AdminSettingsForm'
File
- src/
Form/ AdminSettingsForm.php, line 12
Namespace
Drupal\mass_contact\FormView source
class AdminSettingsForm extends SettingsFormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'mass_contact_admin_settings';
}
/**
* {@inheritdoc}
*/
protected function getConfigKeys() {
return [
'form_information',
'recipient_limit',
'send_with_cron',
'optout_enabled',
'create_archive_copy',
'hourly_threshold',
'category_display',
];
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form = parent::buildForm($form, $form_state);
$config = $this
->config('mass_contact.settings');
$form['form_information'] = [
'#type' => 'textarea',
'#title' => $this
->t('Additional information for Mass Contact form'),
'#default_value' => $config
->get('form_information'),
'#description' => $this
->t('Information to show on the <a href=":url">Mass Contact page</a>.', [
':url' => Url::fromRoute('entity.mass_contact_message.add_form')
->toString(),
]),
];
// Rate limiting options.
$form['limiting_options'] = [
'#type' => 'details',
'#open' => TRUE,
'#title' => $this
->t('Rate limiting options'),
'#description' => $this
->t('By combining the two options below, messages sent through this module will be queued to be sent drung cron runs. Keep in mind that if you set your number of recipients to be the same as your limit, messages from this or other modules may be blocked by your hosting provider.'),
];
// The maximum number of users to send to at one time.
$form['limiting_options']['recipient_limit'] = [
'#type' => 'number',
'#title' => $this
->t('Maximum number of recipients before splitting up the email'),
'#min' => 0,
'#default_value' => $config
->get('recipient_limit'),
'#description' => $this
->t('This is a workaround for server-side limits on the number of recipients in a single mail message. Once this limit is reached, the recipient list will be broken up and multiple copies of the message will be sent out until all recipients receive the mail. Setting this to 0 (zero) will turn this feature off.'),
'#required' => TRUE,
];
// The maximum number of users to send to at one time.
$form['mass_contact_rate_limiting_options']['send_with_cron'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Send messages with Cron'),
'#default_value' => $config
->get('send_with_cron'),
'#description' => $this
->t('This is another workaround for server-side limits. Check this box to delay sending until the next Cron run(s).'),
];
// Opt out options.
$form['mass_contact_optout_options'] = [
'#type' => 'details',
'#title' => $this
->t('Opt-out options'),
];
// @todo Refactor this when adding optout functionality to utilize a field.
$form['mass_contact_optout_options']['optout_enabled'] = [
'#type' => 'radios',
'#title' => $this
->t('Allow users to opt-out of mass email messages'),
'#default_value' => $config
->get('optout_enabled'),
'#options' => [
MassContactInterface::OPT_OUT_DISABLED => $this
->t('No'),
MassContactInterface::OPT_OUT_GLOBAL => $this
->t('Yes'),
MassContactInterface::OPT_OUT_CATEGORY => $this
->t('Selected categories'),
],
'#description' => $this
->t("Allow users to opt-out of receiving mass email messages. If 'No' is chosen, then the site's users will not be able to opt-out of receiving mass email messages. If 'Yes' is chosen, then the site's users will be able to opt-out of receiving mass email messages, and they will not receive any from any category. If 'Selected categories' is chosen, then the site's users will be able to opt-out of receiving mass email messages from which ever categories they choose."),
];
// Node copy options.
$form['create_archive_copy'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Archive messages by saving a copy as a node'),
'#default_value' => $config
->get('create_archive_copy'),
];
// Flood control options.
$form['hourly_threshold'] = [
'#type' => 'number',
'#title' => $this
->t('Hourly threshold'),
'#min' => 0,
'#default_value' => $config
->get('hourly_threshold'),
'#description' => $this
->t('The maximum number of Mass Contact form submissions a user can perform per hour.'),
];
// Category options.
$form['category_display'] = [
'#type' => 'radios',
'#title' => $this
->t('Field to use to display the categories'),
'#default_value' => $config
->get('category_display'),
'#options' => [
'select' => 'Select list',
'checkboxes' => 'Check boxes',
],
'#description' => $this
->t("Select the form field to use to display the available categories to the message sender."),
];
return $form;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AdminSettingsForm:: |
public | function |
Form constructor. Overrides ConfigFormBase:: |
|
AdminSettingsForm:: |
protected | function |
Get config keys to save. Overrides SettingsFormBase:: |
|
AdminSettingsForm:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
ConfigFormBase:: |
public static | function |
Instantiates a new instance of this class. Overrides FormBase:: |
13 |
ConfigFormBase:: |
public | function | Constructs a \Drupal\system\ConfigFormBase object. | 11 |
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. | |
SettingsFormBase:: |
protected | function |
Gets the configuration names that will be editable. Overrides ConfigFormBaseTrait:: |
|
SettingsFormBase:: |
public | function |
Form submission handler. Overrides ConfigFormBase:: |
|
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. |