function social_event_an_enroll_views_post_render in Open Social 8.3
Same name and namespace in other branches
- 8.9 modules/social_features/social_event/modules/social_event_an_enroll/social_event_an_enroll.module \social_event_an_enroll_views_post_render()
- 8.4 modules/social_features/social_event/modules/social_event_an_enroll/social_event_an_enroll.module \social_event_an_enroll_views_post_render()
- 8.5 modules/social_features/social_event/modules/social_event_an_enroll/social_event_an_enroll.module \social_event_an_enroll_views_post_render()
- 8.6 modules/social_features/social_event/modules/social_event_an_enroll/social_event_an_enroll.module \social_event_an_enroll_views_post_render()
- 8.7 modules/social_features/social_event/modules/social_event_an_enroll/social_event_an_enroll.module \social_event_an_enroll_views_post_render()
- 8.8 modules/social_features/social_event/modules/social_event_an_enroll/social_event_an_enroll.module \social_event_an_enroll_views_post_render()
- 10.3.x modules/social_features/social_event/modules/social_event_an_enroll/social_event_an_enroll.module \social_event_an_enroll_views_post_render()
- 10.0.x modules/social_features/social_event/modules/social_event_an_enroll/social_event_an_enroll.module \social_event_an_enroll_views_post_render()
- 10.1.x modules/social_features/social_event/modules/social_event_an_enroll/social_event_an_enroll.module \social_event_an_enroll_views_post_render()
- 10.2.x modules/social_features/social_event/modules/social_event_an_enroll/social_event_an_enroll.module \social_event_an_enroll_views_post_render()
Implements hook_views_post_render().
Alter "Event enrollments" views. Add number of anonymous enrollments.
File
- modules/
social_features/ social_event/ modules/ social_event_an_enroll/ social_event_an_enroll.module, line 95 - The Social event AN enroll module.
Code
function social_event_an_enroll_views_post_render(ViewExecutable $view, &$output, CachePluginBase $cache) {
if ($view
->id() == 'event_enrollments' && $view->current_display == 'event_enrollments') {
if (isset($output['#rows'])) {
if (!empty($view->args[0])) {
$nid = $view->args[0];
$node = Node::load($nid);
$an_count = social_event_an_enroll_count($nid);
if (social_event_an_enroll_is_enabled($node) && $an_count && $an_count > 0) {
// Fix counter in block title.
$view->total_rows += $an_count;
// Add default avatar image with counter.
if (empty($output['#rows'])) {
$output['#rows'][0]['#theme'] = $output['#theme'];
$output['#rows'][0]['#view'] = $output['#view'];
$output['#rows'][0]['#grouping_level'] = 0;
$output['#rows'][0]['#title'] = '';
}
// Get default profile image uri.
$default_image = social_profile_get_default_image();
if (!empty($default_image['id'])) {
$file = File::load($default_image['id']);
$uri = $file
->getFileUri();
$output['#rows'][0]['#rows'][] = [
'#prefix' => '<div class="avatar">',
'#theme' => 'image_style',
'#style_name' => 'social_medium',
'#uri' => $uri,
'#suffix' => '<span class="badge badge--pill">' . $an_count . '</span></div>',
];
}
$output['#attached']['library'][] = 'social_event_an_enroll/event_an_enroll';
}
}
}
}
}