You are here

public function TaxonomyEntityIndexAdminReindexForm::submitForm in Taxonomy Entity Index 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/TaxonomyEntityIndexAdminReindexForm.php, line 101

Class

TaxonomyEntityIndexAdminReindexForm
Provides the reindex form.

Namespace

Drupal\taxonomy_entity_index\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $types = array_filter($form_state
    ->getValue([
    'types',
  ]));

  // Add an operation for each entity type.
  foreach ($types as $type) {
    $operations[] = [
      'taxonomy_entity_index_reindex_entity_type',
      [
        $type,
      ],
    ];
  }

  // Set a batch operation for each selected entity type.
  $batch = [
    'operations' => $operations,
    'finished' => 'taxonomy_entity_index_reindex_finished',
  ];

  // Execute the batch.
  batch_set($batch);
}