function bibcite_entity_merge_entity_finished in Bibliography & Citation 8
Same name and namespace in other branches
- 2.0.x modules/bibcite_entity/bibcite_entity.batch.inc \bibcite_entity_merge_entity_finished()
Batch finished callback.
Parameters
bool $success: A boolean indicating whether the batch has completed successfully.
array $results: The value set in $context['results'] by operation callback.
array $operations: If $success is FALSE, contains the operations that remained unprocessed.
Return value
\Symfony\Component\HttpFoundation\RedirectResponse Redirect to collection route.
2 string references to 'bibcite_entity_merge_entity_finished'
- MergeConfirmForm::submitForm in modules/
bibcite_entity/ src/ Form/ MergeConfirmForm.php - Form submission handler.
- MergeMultipleForm::submitForm in modules/
bibcite_entity/ src/ Form/ MergeMultipleForm.php - Form submission handler.
File
- modules/
bibcite_entity/ bibcite_entity.batch.inc, line 171 - Batch callbacks.
Code
function bibcite_entity_merge_entity_finished($success, array $results, array $operations) {
$string_translation = \Drupal::translation();
$entity_type_manager = \Drupal::entityTypeManager();
$messenger = \Drupal::messenger();
$reference_message = t('@count of @max references successfully processed', [
'@count' => count($results['references']),
'@max' => $results['references_count'],
]);
$messenger
->addStatus($reference_message);
$entity_type = $entity_type_manager
->getDefinition($results['entity_type_id']);
$message = $string_translation
->formatPlural(count($results['entities']), '%label has been successfully merged and deleted', '@count %plural_label have been successfully merged and deleted', [
'%label' => $results['label'],
'%plural_label' => $entity_type
->getPluralLabel(),
]);
$messenger
->addStatus($message);
if (!empty($results['failed'])) {
$messenger
->addError(t("These @entity_type processed with errors and have not been deleted:\n", [
'@entity_type' => $entity_type
->getPluralLabel(),
]));
foreach ($results['failed'] as $id => $label) {
$messenger
->addError("{$label} ({$id})\n");
}
}
$redirect_url = new Url("entity.{$results['entity_type_id']}.collection");
return new RedirectResponse($redirect_url
->toString());
}