Skip to content
Snippets Groups Projects

Resolve #3184476 "Domain flag"

Merged Eli requested to merge issue/config_notify-3184476:3184476-domain-flag into 8.x-1.x
2 files
+ 59
9
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -164,6 +164,31 @@ class ConfigNotifySettingsForm extends ConfigFormBase {
],
];
$form['add_host'] = [
'#type' => 'checkbox',
'#title' => $this->t('Send host information'),
'#description' => $this->t("Adds host information into notifications."),
'#default_value' => $config->get('add_host'),
];
$host = \Drupal::request()->getSchemeAndHttpHost();
$form['custom_host_value'] = [
'#type' => 'textfield',
'#title' => $this->t('Custom host value'),
'#description' => $this->t('Add a custom value to be sent with notifications. Leave empty for %current (current host)', ['%current' => $host]),
'#default_value' => $config->get('custom_host_value'),
'#attributes' => [
'placeholder' => $host,
],
'#states' => [
'visible' => [
':checkbox[name="add_host"]' => [
'checked' => TRUE,
],
],
],
];
$form['notification_types'] = [
'#markup' => '<hr /><h3>' . $this->t('Notification types') . '</h3>',
];
@@ -193,7 +218,7 @@ class ConfigNotifySettingsForm extends ConfigFormBase {
];
if ($this->moduleHandler->moduleExists('slack')) {
$is_slack_configured = \Drupal::config('slack.settings')->get('slack_webhook_url') ?: NULL;
$is_slack_configured = \Drupal::config('slack.settings')->get('slack_webhook_url') ?: NULL;
$form['slack'] = [
'#type' => 'checkbox',
'#title' => $this->t('Slack notification'),
@@ -206,12 +231,8 @@ class ConfigNotifySettingsForm extends ConfigFormBase {
if (!$is_slack_configured) {
$url = Url::fromRoute('slack.admin_settings');
$link = Link::fromTextAndUrl('here', $url)->toString();
$form['slack_message'] = [
'#markup' => '<p>' .
$this->t('NOTICE: While Slack module is enabled, it is not properly configured. Please configure Slack ')
. $link
. '</p>',
'#markup' => '<p>' . $this->t('NOTICE: While Slack module is enabled, it is not properly configured. Please <a href="@configure-slack">configure Slack</a>.', ['@configure-slack' => $url->toString()]) . '</p>',
];
}
}
@@ -300,6 +321,8 @@ class ConfigNotifySettingsForm extends ConfigFormBase {
$slack = $form_state->getValue('slack');
$list_changes = $form_state->getValue('list_changes');
$list_changes_limit = $form_state->getValue('list_changes_limit');
$add_host = $form_state->getValue('add_host');
$custom_host_value = $form_state->getValue('custom_host_value');
$this->config('config_notify.settings')
->set('cron', $cron)
@@ -309,6 +332,8 @@ class ConfigNotifySettingsForm extends ConfigFormBase {
->set('email_to', $email_to)
->set('list_changes', $list_changes)
->set('list_changes_limit', $list_changes_limit)
->set('add_host', $add_host)
->set('custom_host_value', $custom_host_value)
->save();
}
Loading