You are here

function social_profile_block_access in Open Social 10.1.x

Same name and namespace in other branches
  1. 10.3.x modules/social_features/social_profile/social_profile.module \social_profile_block_access()
  2. 10.2.x modules/social_features/social_profile/social_profile.module \social_profile_block_access()

Show exposed filters block only when tagging filters are enabled for profile.

Implements hook_block_access().

File

modules/social_features/social_profile/social_profile.module, line 892
The Social profile module.

Code

function social_profile_block_access(Block $block, $operation, AccountInterface $account) {
  if ($operation === 'view' && $block
    ->getPluginId() === 'views_exposed_filter_block:newest_users-page_newest_users') {
    $access = AccessResult::forbidden();
    if (\Drupal::moduleHandler()
      ->moduleExists('social_tagging')) {

      /** @var \Drupal\social_tagging\SocialTaggingService $tag_service */
      $tag_service = \Drupal::service('social_tagging.tag_service');
      if ($tag_service
        ->profileActive()) {
        $access = AccessResult::allowed();
      }
    }
    return $access;
  }

  // No opinion.
  return AccessResult::neutral();
}