You are here

public function TaxonomyDeleteUIForm::submitForm in Taxonomy Delete 8

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FormInterface::submitForm

File

src/Form/TaxonomyDeleteUIForm.php, line 48

Class

TaxonomyDeleteUIForm
Class TaxonomyDeleteUIForm.

Namespace

Drupal\taxonomy_delete\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $selected_vocabulary = array_filter($form_state
    ->getValue('vocabulary'));
  foreach ($selected_vocabulary as $vid) {

    // Batch process the vocabulary to delete the terms in it.
    $batch = [
      'operations' => [
        [
          '\\Drupal\\taxonomy_delete\\TaxonomyDeleteBatch::processVocabulary',
          [
            $vid,
          ],
        ],
      ],
      'finished' => '\\Drupal\\taxonomy_delete\\TaxonomyDeleteBatch::finishProcess',
    ];
    batch_set($batch);
  }
}