You are here

public function QueuerDeleteForm::deleteQueuer in Purge 8.3

Delete the queuer.

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

\Drupal\Core\Ajax\AjaxResponse The AJAX response object.

File

modules/purge_ui/src/Form/QueuerDeleteForm.php, line 126

Class

QueuerDeleteForm
Delete queuer {id}.

Namespace

Drupal\purge_ui\Form

Code

public function deleteQueuer(array &$form, FormStateInterface $form_state) {
  $response = new AjaxResponse();
  $enabled = $this->purgeQueuers
    ->getPluginsEnabled();
  $id = $form_state
    ->getBuildInfo()['args'][0];
  if (in_array($id, $enabled)) {
    foreach ($enabled as $i => $plugin_id) {
      if ($id === $plugin_id) {
        unset($enabled[$i]);
      }
    }
    $this->purgeQueuers
      ->setPluginsEnabled($enabled);
    $response
      ->addCommand(new ReloadConfigFormCommand('edit-queue'));
  }
  $response
    ->addCommand(new CloseModalDialogCommand());
  return $response;
}