function _social_group_action_batch_finish in Open Social 8.9
Same name and namespace in other branches
- 8.5 modules/social_features/social_group/social_group.module \_social_group_action_batch_finish()
- 8.6 modules/social_features/social_group/social_group.module \_social_group_action_batch_finish()
- 8.7 modules/social_features/social_group/social_group.module \_social_group_action_batch_finish()
- 8.8 modules/social_features/social_group/social_group.module \_social_group_action_batch_finish()
- 10.3.x modules/social_features/social_group/social_group.module \_social_group_action_batch_finish()
- 10.0.x modules/social_features/social_group/social_group.module \_social_group_action_batch_finish()
- 10.1.x modules/social_features/social_group/social_group.module \_social_group_action_batch_finish()
- 10.2.x modules/social_features/social_group/social_group.module \_social_group_action_batch_finish()
Action batch finished callback.
Parameters
bool $success: Was the process successfull?
array $results: Batch process results array.
array $operations: Performed operations array.
1 string reference to '_social_group_action_batch_finish'
- social_group_batch_alter in modules/
social_features/ social_group/ social_group.module - Implements hook_batch_alter().
File
- modules/
social_features/ social_group/ social_group.module, line 2178 - The Social group module.
Code
function _social_group_action_batch_finish($success, array $results, array $operations) {
// When we do a bulk action on all the items in a view, across multiple pages,
// the saveList function needs to be called. So after pre-populating the list
// the actual action is performed on the entities.
if (!empty($results['view_id']) && !empty($results['display_id'])) {
ViewsBulkOperationsBatch::saveList(TRUE, $results, $operations);
return;
}
$operations = array_count_values($results['operations']);
$results_count = 0;
foreach ($operations as $count) {
$results_count += $count;
}
$hook = 'social_group_action_' . $results['action'] . '_finish';
foreach (\Drupal::moduleHandler()
->getImplementations($hook) as $module) {
$function = $module . '_' . $hook;
$messages = $function($success);
if (is_array($messages)) {
$fields = 0;
foreach ($messages as $type => $message) {
if (($type === 'singular' || $type === 'plural') && !empty($message) && is_string($message)) {
$fields++;
}
}
if ($fields === 2) {
$message = \Drupal::translation()
->formatPlural($results_count, $messages['singular'], $messages['plural']);
$type = $success ? MessengerInterface::TYPE_STATUS : MessengerInterface::TYPE_WARNING;
\Drupal::messenger()
->addMessage($message, $type);
}
}
}
}