You are here

public function MessageSettingsForm::buildForm in Message 8

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

src/Form/MessageSettingsForm.php, line 85

Class

MessageSettingsForm
Configure file system settings for this site.

Namespace

Drupal\message\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('message.settings');

  // Uses the same form keys as the MessageTemplateForm so that the purge
  // plugins form can be re-used.
  $form['settings'] = [
    '#type' => 'fieldset',
    '#title' => t('Purge settings'),
    '#tree' => TRUE,
  ];
  $form['settings']['purge_enable'] = [
    '#type' => 'checkbox',
    '#title' => t('Purge messages'),
    '#description' => t('Configure how messages will be deleted.'),
    '#default_value' => $config
      ->get('purge_enable'),
  ];

  // Add the purge method settings form.
  $this->purgeManager
    ->purgeSettingsForm($form, $form_state, $config
    ->get('purge_methods'));
  $form['delete_on_entity_delete'] = [
    '#title' => t('Auto delete messages referencing the following entities'),
    '#type' => 'select',
    '#multiple' => TRUE,
    '#options' => $this
      ->getContentEntityTypes(),
    '#default_value' => $config
      ->get('delete_on_entity_delete'),
    '#description' => t('Messages that reference entities of these types will be deleted when the referenced entity gets deleted.'),
  ];
  return parent::buildForm($form, $form_state);
}