public static function ImportBatchHelper::importUrlBatchFinished in Entity Share 8.3
Batch finish callback.
Parameters
bool $success: A boolean indicating whether the batch has completed successfully.
array $results: The value set in $context['results'] by callback_batch_operation().
array $operations: If $success is FALSE, contains the operations that remained unprocessed.
File
- modules/
entity_share_client/ src/ ImportBatchHelper.php, line 74
Class
- ImportBatchHelper
- Class ImportBatchHelper.
Namespace
Drupal\entity_share_clientCode
public static function importUrlBatchFinished($success, array $results, array $operations) {
if ($success) {
$language_manager = \Drupal::languageManager();
$total = 0;
// Count for each language.
// Currently not possible to have details like entity type or bundle.
// This would require a rework on how imported entities tracking work.
foreach ($results['imported_entity_ids'] as $langcode => $entity_uuids) {
$language = $language_manager
->getLanguage($langcode);
$language_count = count($entity_uuids);
$total += $language_count;
$message = new PluralTranslatableMarkup($language_count, 'One entity imported in @language_label.', '@count entities imported in @language_label.', [
'@language_label' => $language
->getName(),
]);
\Drupal::messenger()
->addStatus($message);
}
$message = new PluralTranslatableMarkup($total, 'One entity imported in total.', '@count entities imported in total.');
\Drupal::messenger()
->addStatus($message);
}
else {
$message = t('Finished with an error.');
\Drupal::messenger()
->addError($message);
}
}