You are here

function message_ui_form_message_system_settings_alter in Message UI 8

Implements hook_form_FORM_ID_alter().

File

./message_ui.module, line 156
Contains Drupal\message_ui\message_ui.module.

Code

function message_ui_form_message_system_settings_alter(&$form, FormStateInterface $form_state) {
  $form['update_tokens'] = [
    '#type' => 'fieldset',
    '#itle' => t('Token update settings'),
  ];
  $message_ui_settings = \Drupal::config('message_ui.settings');
  $form['update_tokens']['update_tokens_update_tokens'] = [
    '#type' => 'checkbox',
    '#title' => t('Update messages arguments'),
    '#description' => t('When editing a message template, the user can add or delete arguments. When this is checked, you can choose how to update to messages arguments.'),
    '#default_value' => $message_ui_settings
      ->get('update_tokens.update_tokens'),
  ];
  $form['update_tokens']['update_tokens_how_to_act'] = [
    '#type' => 'select',
    '#title' => t('Choose how to act'),
    '#default_value' => $message_ui_settings
      ->get('update_tokens.how_to_act'),
    '#options' => [
      'update_when_removed' => t('Update messages when tokens are removed'),
      'update_when_added' => t('Update messages when tokens are added'),
    ],
    '#states' => [
      'visible' => [
        ':input[name="update_tokens_update_tokens"]' => [
          'checked' => TRUE,
        ],
      ],
    ],
  ];
  $form['update_tokens']['update_tokens_how_to_update'] = [
    '#type' => 'select',
    '#title' => t('Choose how to update the messages'),
    '#default_value' => $message_ui_settings
      ->get('update_tokens.how_to_update'),
    '#options' => [
      'update_with_batch' => t('Update messages with batch API'),
      'update_with_item' => t('Update messages with queue item'),
    ],
    '#states' => [
      'visible' => [
        ':input[name="update_tokens_update_tokens"]' => [
          'checked' => TRUE,
        ],
      ],
    ],
  ];
  $form['update_tokens']['update_tokens_number_items'] = [
    '#type' => 'textfield',
    '#size' => '10',
    '#title' => t('Items to process each time.'),
    '#description' => t('Choose how much items to process each iteration.'),
    '#default_value' => $message_ui_settings
      ->get('update_tokens.number_items'),
    '#states' => [
      'visible' => [
        ':input[name="update_tokens_update_tokens"]' => [
          'checked' => TRUE,
        ],
      ],
    ],
  ];
  $form['message_ui_show_preview'] = [
    '#type' => 'checkbox',
    '#title' => t('Show/hide preview'),
    '#default_value' => $message_ui_settings
      ->get('show_preview'),
    '#description' => t('Show/hide the text of the message when editing an instance of the message.'),
  ];
  $form['#submit'][] = 'message_ui_form_message_system_settings_submit';
}