protected function AutoEntityLabelForm::setBatch in Automatic Entity Label 8.3
1 call to AutoEntityLabelForm::setBatch()
- AutoEntityLabelForm::submitForm in src/
Form/ AutoEntityLabelForm.php - Form submission handler.
File
- src/
Form/ AutoEntityLabelForm.php, line 308
Class
- AutoEntityLabelForm
- Class AutoEntityLabelForm.
Namespace
Drupal\auto_entitylabel\FormCode
protected function setBatch($entity_type, $bundle, $chunk) {
$ids = $this
->getIds($entity_type, $bundle);
$chunks = array_chunk($ids, $chunk);
$num_chunks = count($chunks);
// Re-save all labels chunk by chunk.
$operations = [];
for ($chunk_iterator = 0; $chunk_iterator < $num_chunks; $chunk_iterator++) {
$operations[] = [
'\\Drupal\\auto_entitylabel\\Batch\\ResaveBatch::batchOperation',
[
$chunks[$chunk_iterator],
[
$bundle,
],
],
];
}
$batch = [
'title' => $this
->t('Re-saving labels'),
'progress_message' => $this
->t('Completed @current out of @total chunks.'),
'finished' => '\\Drupal\\auto_entitylabel\\Batch\\ResaveBatch::batchFinished',
'operations' => $operations,
];
batch_set($batch);
}