function batch_example_finished
Same name in other branches
- 3.x modules/batch_example/batch_example.module \batch_example_finished()
- 7.x-1.x batch_example/batch_example.module \batch_example_finished()
- 6.x-1.x batch_example/batch_example.module \batch_example_finished()
- 4.0.x modules/batch_example/batch_example.module \batch_example_finished()
Batch 'finished' callback used by both batch 1 and batch 2.
Related topics
2 string references to 'batch_example_finished'
- BatchExampleForm::generateBatch1 in batch_example/
src/ Form/ BatchExampleForm.php - Generate Batch 1.
- BatchExampleForm::generateBatch2 in batch_example/
src/ Form/ BatchExampleForm.php - Generate Batch 2.
File
-
batch_example/
batch_example.module, line 109
Code
function batch_example_finished($success, $results, $operations) {
$messenger = \Drupal::messenger();
if ($success) {
// Here we could do something meaningful with the results.
// We just display the number of nodes we processed...
$messenger->addMessage(t('@count results processed.', [
'@count' => count($results),
]));
$messenger->addMessage(t('The final result was "%final"', [
'%final' => end($results),
]));
}
else {
// An error occurred.
// $operations contains the operations that remained unprocessed.
$error_operation = reset($operations);
$messenger->addMessage(t('An error occurred while processing @operation with arguments : @args', [
'@operation' => $error_operation[0],
'@args' => print_r($error_operation[0], TRUE),
]));
}
}