function social_group_invite_preprocess_views_view in Open Social 8.9
Same name and namespace in other branches
- 10.3.x modules/social_features/social_group/modules/social_group_invite/social_group_invite.module \social_group_invite_preprocess_views_view()
- 10.0.x modules/social_features/social_group/modules/social_group_invite/social_group_invite.module \social_group_invite_preprocess_views_view()
- 10.1.x modules/social_features/social_group/modules/social_group_invite/social_group_invite.module \social_group_invite_preprocess_views_view()
- 10.2.x modules/social_features/social_group/modules/social_group_invite/social_group_invite.module \social_group_invite_preprocess_views_view()
Implements hook_preprocess_HOOK().
1 string reference to 'social_group_invite_preprocess_views_view'
- social_group_invite_theme_registry_alter in modules/
social_features/ social_group/ modules/ social_group_invite/ social_group_invite.module - Implements hook_theme_registry_alter().
File
- modules/
social_features/ social_group/ modules/ social_group_invite/ social_group_invite.module, line 109 - The Social Invite group module.
Code
function social_group_invite_preprocess_views_view(&$variables) {
/** @var \Drupal\views\ViewExecutable $view */
$view =& $variables['view'];
if ($view
->id() === 'group_manage_members') {
$entity = \Drupal::entityTypeManager()
->getStorage('block')
->load('socialblue_local_actions');
$variables['header']['actions'] = \Drupal::entityTypeManager()
->getViewBuilder('block')
->view($entity);
}
// See function social_group_preprocess_views_view(&$variables).
// 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.
// Get current group so we can build correct links.
if ($view
->id() === 'group_manage_members') {
if (_social_group_invite_current_type_enabled_invites()) {
$entity = \Drupal::entityTypeManager()
->getStorage('block')
->load('socialinviteactionsblock');
if (NULL !== $entity) {
$block_content = \Drupal::entityTypeManager()
->getViewBuilder('block')
->view($entity);
if (!empty($block_content)) {
$variables['header']['actions'] = $block_content;
}
}
}
else {
$entity = \Drupal::entityTypeManager()
->getStorage('block')
->load('socialblue_local_actions');
$variables['header']['actions'] = \Drupal::entityTypeManager()
->getViewBuilder('block')
->view($entity);
}
}
// Implement button to go back to the group for our custom view.
if ($variables['view']
->id() === 'social_group_invitations') {
$group = _social_group_get_current_group();
$variables['more'] = [
'#title' => t('Back to group'),
'#type' => 'link',
'#url' => Url::fromRoute('entity.group.canonical', [
'group' => $group
->id(),
]),
'#attributes' => [
'class' => [
'btn',
'btn-default',
'btn-raised',
'waves-effect',
],
],
];
}
}