You are here

public function BatchUpdateForm::generateBatch in Entity Usage 8

Same name and namespace in other branches
  1. 8.3 src/Form/BatchUpdateForm.php \Drupal\entity_usage\Form\BatchUpdateForm::generateBatch()

Create a batch to process the entity types in bulk.

Parameters

string[] $types: An array of entity types ids.

Return value

array The batch array.

1 call to BatchUpdateForm::generateBatch()
BatchUpdateForm::submitForm in src/Form/BatchUpdateForm.php
Form submission handler.

File

src/Form/BatchUpdateForm.php, line 111

Class

BatchUpdateForm
Form to launch batch tracking of existing entities.

Namespace

Drupal\entity_usage\Form

Code

public function generateBatch(array $types) {
  $operations = [];
  foreach ($types as $type) {
    $operations[] = [
      'Drupal\\entity_usage\\Form\\BatchUpdateForm::updateHostsBatchWorker',
      [
        $type,
      ],
    ];
  }
  $batch = [
    'operations' => $operations,
    'finished' => 'Drupal\\entity_usage\\Form\\BatchUpdateForm::batchFinished',
    'title' => $this
      ->t('Updating entity usage statistics.'),
    'progress_message' => $this
      ->t('Processed @current of @total entity types.'),
    'error_message' => $this
      ->t('This batch encountered an error.'),
  ];
  return $batch;
}