public function SocialSwiftmailSettingsForm::buildForm in Open Social 10.3.x
Same name and namespace in other branches
- 8.9 modules/social_features/social_swiftmail/src/Form/SocialSwiftmailSettingsForm.php \Drupal\social_swiftmail\Form\SocialSwiftmailSettingsForm::buildForm()
- 8.2 modules/social_features/social_swiftmail/src/Form/SocialSwiftmailSettingsForm.php \Drupal\social_swiftmail\Form\SocialSwiftmailSettingsForm::buildForm()
- 8.3 modules/social_features/social_swiftmail/src/Form/SocialSwiftmailSettingsForm.php \Drupal\social_swiftmail\Form\SocialSwiftmailSettingsForm::buildForm()
- 8.4 modules/social_features/social_swiftmail/src/Form/SocialSwiftmailSettingsForm.php \Drupal\social_swiftmail\Form\SocialSwiftmailSettingsForm::buildForm()
- 8.5 modules/social_features/social_swiftmail/src/Form/SocialSwiftmailSettingsForm.php \Drupal\social_swiftmail\Form\SocialSwiftmailSettingsForm::buildForm()
- 8.6 modules/social_features/social_swiftmail/src/Form/SocialSwiftmailSettingsForm.php \Drupal\social_swiftmail\Form\SocialSwiftmailSettingsForm::buildForm()
- 8.7 modules/social_features/social_swiftmail/src/Form/SocialSwiftmailSettingsForm.php \Drupal\social_swiftmail\Form\SocialSwiftmailSettingsForm::buildForm()
- 8.8 modules/social_features/social_swiftmail/src/Form/SocialSwiftmailSettingsForm.php \Drupal\social_swiftmail\Form\SocialSwiftmailSettingsForm::buildForm()
- 10.0.x modules/social_features/social_swiftmail/src/Form/SocialSwiftmailSettingsForm.php \Drupal\social_swiftmail\Form\SocialSwiftmailSettingsForm::buildForm()
- 10.1.x modules/social_features/social_swiftmail/src/Form/SocialSwiftmailSettingsForm.php \Drupal\social_swiftmail\Form\SocialSwiftmailSettingsForm::buildForm()
- 10.2.x modules/social_features/social_swiftmail/src/Form/SocialSwiftmailSettingsForm.php \Drupal\social_swiftmail\Form\SocialSwiftmailSettingsForm::buildForm()
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides ConfigFormBase::buildForm
File
- modules/
social_features/ social_swiftmail/ src/ Form/ SocialSwiftmailSettingsForm.php, line 94
Class
- SocialSwiftmailSettingsForm
- Class SocialSwiftmailSettingsForm.
Namespace
Drupal\social_swiftmail\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('social_swiftmail.settings');
$form['notification'] = [
'#type' => 'details',
'#title' => $this
->t('Default email notification settings'),
'#open' => FALSE,
];
// Settings helper for admins.
$form['notification']['helper'] = [
'#type' => 'html_tag',
'#tag' => 'p',
'#value' => $this
->t('<b>Please note:</b> the change below will not impact the users who have changed their default email notification settings.'),
];
// Get grouped default templates.
$items = _activity_send_email_default_template_items();
// Get all message templates.
$email_message_templates = $this->emailActivityDestination
->getSendEmailMessageTemplates();
// Alter message templates and add them to specific group.
$this->moduleHandler
->alter('activity_send_email_notifications', $items, $email_message_templates);
// Sort a list of email frequencies by weight.
$email_frequencies = sort_email_frequency_options();
$notification_options = [];
// Place the sorted data in an actual form option.
foreach ($email_frequencies as $option) {
$notification_options[$option['id']] = $option['name'];
}
$template_frequencies = $config
->get('template_frequencies') ?: [];
foreach ($items as $item_id => $item) {
$rows = [];
foreach ($item['templates'] as $template) {
$rows[] = $this
->buildRow($template, $notification_options, $template_frequencies);
}
$form['notification'][$item_id] = [
'#type' => 'table',
'#caption' => [
'#markup' => '<h6>' . $item['title'] . '</h6>',
],
'#rows' => $rows,
];
}
$form['template'] = [
'#type' => 'details',
'#title' => $this
->t('Template configuration'),
'#open' => FALSE,
];
$template_header = $config
->get('template_header');
$form['template']['template_header'] = [
'#title' => $this
->t('Template header'),
'#type' => 'text_format',
'#default_value' => $template_header['value'] ?: '',
'#format' => $template_header['format'] ?: 'mail_html',
'#allowed_formats' => [
'mail_html',
],
'#description' => $this
->t('Enter information you want to show in the email notifications header'),
];
$template_footer = $config
->get('template_footer');
$form['template']['template_footer'] = [
'#title' => $this
->t('Template footer'),
'#type' => 'text_format',
'#default_value' => $template_footer['value'] ?: '',
'#format' => $template_footer['format'] ?: 'mail_html',
'#allowed_formats' => [
'mail_html',
],
'#description' => $this
->t('Enter information you want to show in the email notifications footer'),
];
$form['remove_open_social_branding'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Remove Open Social Branding'),
'#description' => $this
->t('Open Social Branding will be replaced by site name (and slogan if available).'),
'#default_value' => $config
->get('remove_open_social_branding'),
];
$form['do_not_send_emails_new_users'] = [
'#type' => 'checkbox',
'#title' => $this
->t("Don't send email notifications to users who have never logged in"),
'#description' => $this
->t('When this setting is enabled, users who have never logged in will not receive email notifications, they still receive notifications via the notification centre within the community.'),
'#default_value' => $config
->get('do_not_send_emails_new_users'),
];
return parent::buildForm($form, $form_state);
}