You are here

public function QueueExampleForm::submitDeleteQueue in Examples for Developers 8

Submit handler for clearing/deleting the queue.

Parameters

array $form: Form definition array.

\Drupal\Core\Form\FormStateInterface $form_state: Form state object.

File

queue_example/src/Forms/QueueExampleForm.php, line 412

Class

QueueExampleForm
Form with examples on how to use queue.

Namespace

Drupal\queue_example\Forms

Code

public function submitDeleteQueue(array &$form, FormStateInterface $form_state) {
  $queue = $this->queueFactory
    ->get($form_state
    ->getValue('queue_name'));
  $queue
    ->deleteQueue();
  $this
    ->messenger()
    ->addMessage($this
    ->t('Deleted the @queue_name queue and all items in it', [
    '@queue_name' => $form_state
      ->getValue('queue_name'),
  ]));
}