function social_topic_block_access in Open Social 8.5
Same name and namespace in other branches
- 8.9 modules/social_features/social_topic/social_topic.module \social_topic_block_access()
- 8.3 modules/social_features/social_topic/social_topic.module \social_topic_block_access()
- 8.4 modules/social_features/social_topic/social_topic.module \social_topic_block_access()
- 8.6 modules/social_features/social_topic/social_topic.module \social_topic_block_access()
- 8.7 modules/social_features/social_topic/social_topic.module \social_topic_block_access()
- 8.8 modules/social_features/social_topic/social_topic.module \social_topic_block_access()
- 10.3.x modules/social_features/social_topic/social_topic.module \social_topic_block_access()
- 10.0.x modules/social_features/social_topic/social_topic.module \social_topic_block_access()
- 10.1.x modules/social_features/social_topic/social_topic.module \social_topic_block_access()
- 10.2.x modules/social_features/social_topic/social_topic.module \social_topic_block_access()
Custom permission check, to see if people have access to users' topics.
Implements hook_block_access().
File
- modules/
social_features/ social_topic/ social_topic.module, line 256 - The Social topic module.
Code
function social_topic_block_access(Block $block, $operation, AccountInterface $account) {
if ($operation === 'view' && ($block
->getPluginId() === 'views_exposed_filter_block:topics-page_profile' || $block
->getPluginId() === 'views_block:topics-block_user_topics')) {
// Here we're going to assume by default access is not granted.
$topicController = SocialTopicController::create(\Drupal::getContainer());
$access = $topicController
->myTopicAccess($account);
// If the 'myTopicAccess' returns 'AccessResultNeutral', we have to assume
// that access must be denied.
if ($access instanceof AccessResultNeutral) {
// Return forbidden, since access was not explicitly granted.
return AccessResult::forbidden();
}
return $access;
}
// No opinion.
return AccessResult::neutral();
}