You are here

public function QueueChangeForm::buildForm in Purge 8.3

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 FormInterface::buildForm

File

modules/purge_ui/src/Form/QueueChangeForm.php, line 52

Class

QueueChangeForm
The queue data browser.

Namespace

Drupal\purge_ui\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['#attached']['library'][] = 'core/drupal.dialog.ajax';
  $form['warning'] = [
    '#prefix' => '<p>',
    '#suffix' => '</p>',
    '#markup' => $this
      ->t("<p>The queue engine is the underlying plugin which stores, retrieves and deletes invalidation instructions in the system. When queuers add items to the queue or when processors claim items from it, it is this engine that stores it physically. For most cases the <b>database</b> engine is sufficient, however, in extremely busy scenarios more efficient engines can bring the necessary relief.</p><p><b>Warning: </b> when you change the queue, it will be emptied as well!</p>"),
  ];
  $form['plugin_id'] = [
    '#type' => 'tableselect',
    '#default_value' => current($this->purgeQueue
      ->getPluginsEnabled()),
    '#responsive' => TRUE,
    '#multiple' => FALSE,
    '#options' => [],
    '#header' => [
      'label' => $this
        ->t('Engine'),
      'description' => $this
        ->t('Description'),
    ],
  ];
  foreach ($this->purgeQueue
    ->getPlugins() as $plugin_id => $definition) {
    $form['plugin_id']['#options'][$plugin_id] = [
      'label' => $definition['label'],
      'description' => $definition['description'],
    ];
  }
  $form['actions'] = [
    '#type' => 'actions',
  ];
  $form['actions']['cancel'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t('Cancel'),
    '#weight' => -10,
    '#button_type' => 'primary',
    '#ajax' => [
      'callback' => '::closeDialog',
    ],
  ];
  $form['actions']['submit'] = [
    '#type' => 'submit',
    '#value' => $this
      ->t("Change"),
    '#button_type' => 'danger',
    '#ajax' => [
      'callback' => '::changeQueue',
    ],
  ];
  return $form;
}