You are here

function social_group_request_views_pre_view in Open Social 10.3.x

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_group/modules/social_group_request/social_group_request.module \social_group_request_views_pre_view()
  2. 10.0.x modules/social_features/social_group/modules/social_group_request/social_group_request.module \social_group_request_views_pre_view()
  3. 10.1.x modules/social_features/social_group/modules/social_group_request/social_group_request.module \social_group_request_views_pre_view()
  4. 10.2.x modules/social_features/social_group/modules/social_group_request/social_group_request.module \social_group_request_views_pre_view()

Implements hook_views_pre_view().

File

modules/social_features/social_group/modules/social_group_request/social_group_request.module, line 383
Primary module hooks for social_group_request module.

Code

function social_group_request_views_pre_view(ViewExecutable $view, $display_id, array &$args) {
  if ($view
    ->id() === 'group_pending_members' && $display_id === 'membership_requests') {
    $options = [
      'id' => 'area_text_custom',
      'table' => 'views',
      'field' => 'area_text_custom',
      'relationship' => 'none',
      'group_type' => 'none',
      'admin_label' => '',
      'empty' => TRUE,
      'tokenize' => FALSE,
      'content' => Link::fromTextAndUrl(t('Back to group'), Url::fromRoute('entity.group.canonical', [
        'group' => $args[0],
      ], [
        'attributes' => [
          'class' => [
            'btn',
            'btn-default',
          ],
        ],
      ]))
        ->toString(),
      'plugin_id' => 'text_custom',
    ];
    $view
      ->setHandler('membership_requests', 'footer', 'area_text_custom', $options);
    $view->element['#attached']['library'][] = 'social_group_request/social_group_table';
  }
}