function social_event_invite_preprocess_views_view in Open Social 10.2.x
Same name and namespace in other branches
- 8.9 modules/social_features/social_event/modules/social_event_invite/social_event_invite.module \social_event_invite_preprocess_views_view()
- 10.3.x modules/social_features/social_event/modules/social_event_invite/social_event_invite.module \social_event_invite_preprocess_views_view()
- 10.0.x modules/social_features/social_event/modules/social_event_invite/social_event_invite.module \social_event_invite_preprocess_views_view()
- 10.1.x modules/social_features/social_event/modules/social_event_invite/social_event_invite.module \social_event_invite_preprocess_views_view()
Implements template_preprocess_views_view().
1 string reference to 'social_event_invite_preprocess_views_view'
- social_event_invite_theme_registry_alter in modules/
social_features/ social_event/ modules/ social_event_invite/ social_event_invite.module - Implements hook_theme_registry_alter().
File
- modules/
social_features/ social_event/ modules/ social_event_invite/ social_event_invite.module, line 132 - The Social event invite enroll module.
Code
function social_event_invite_preprocess_views_view(&$variables) {
if ($variables['view']
->id() === 'event_manage_enrollment_invites') {
$node_id = \Drupal::routeMatch()
->getParameter('node');
// Implement custom button to go back to the event.
$variables['more'] = [
'#title' => t('Back to event'),
'#type' => 'link',
'#url' => Url::fromRoute('entity.node.canonical', [
'node' => (int) $node_id,
]),
'#attributes' => [
'class' => [
'btn',
'btn-default',
'btn-raised',
'waves-effect',
],
],
];
}
// We have to override the local actions block.
// and render our own block instance in the view for placement.
// hook_theme_registry_alter will ensure our hooks is invoked later.
// That is also why hook_menu_local_actions_alter won't work.
if ($variables['view']
->id() === 'event_manage_enrollments') {
/** @var \Drupal\social_event_invite\SocialEventInviteAccessHelper $access */
$access = \Drupal::service('social_event_invite.access_helper');
$access = $access
->eventFeatureAccess();
if (!$access instanceof AccessResultForbidden) {
// Add the roster-link block to the build-array.
/** @var \Drupal\social_event_invite\Plugin\Block\SocialEventInviteLocalActionsBlock $block */
$block = \Drupal::service('plugin.manager.block')
->createInstance('social_event_invite_block');
if (NULL !== $block) {
$block
->setContextValue('node', Node::load(\Drupal::routeMatch()
->getParameter('node')));
$block_content = $block
->build();
if (!empty($block_content)) {
$variables['header']['actions'] = $block_content;
}
}
}
}
}