You are here

protected function TopicAddBlock::blockAccess in Open Social 10.0.x

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_topic/src/Plugin/Block/TopicAddBlock.php \Drupal\social_topic\Plugin\Block\TopicAddBlock::blockAccess()
  2. 8 modules/social_features/social_topic/src/Plugin/Block/TopicAddBlock.php \Drupal\social_topic\Plugin\Block\TopicAddBlock::blockAccess()
  3. 8.2 modules/social_features/social_topic/src/Plugin/Block/TopicAddBlock.php \Drupal\social_topic\Plugin\Block\TopicAddBlock::blockAccess()
  4. 8.3 modules/social_features/social_topic/src/Plugin/Block/TopicAddBlock.php \Drupal\social_topic\Plugin\Block\TopicAddBlock::blockAccess()
  5. 8.4 modules/social_features/social_topic/src/Plugin/Block/TopicAddBlock.php \Drupal\social_topic\Plugin\Block\TopicAddBlock::blockAccess()
  6. 8.5 modules/social_features/social_topic/src/Plugin/Block/TopicAddBlock.php \Drupal\social_topic\Plugin\Block\TopicAddBlock::blockAccess()
  7. 8.6 modules/social_features/social_topic/src/Plugin/Block/TopicAddBlock.php \Drupal\social_topic\Plugin\Block\TopicAddBlock::blockAccess()
  8. 8.7 modules/social_features/social_topic/src/Plugin/Block/TopicAddBlock.php \Drupal\social_topic\Plugin\Block\TopicAddBlock::blockAccess()
  9. 8.8 modules/social_features/social_topic/src/Plugin/Block/TopicAddBlock.php \Drupal\social_topic\Plugin\Block\TopicAddBlock::blockAccess()
  10. 10.3.x modules/social_features/social_topic/src/Plugin/Block/TopicAddBlock.php \Drupal\social_topic\Plugin\Block\TopicAddBlock::blockAccess()
  11. 10.1.x modules/social_features/social_topic/src/Plugin/Block/TopicAddBlock.php \Drupal\social_topic\Plugin\Block\TopicAddBlock::blockAccess()
  12. 10.2.x modules/social_features/social_topic/src/Plugin/Block/TopicAddBlock.php \Drupal\social_topic\Plugin\Block\TopicAddBlock::blockAccess()

Custom access logic to display the block only on current user Topic page.

Overrides BlockPluginTrait::blockAccess

File

modules/social_features/social_topic/src/Plugin/Block/TopicAddBlock.php, line 65

Class

TopicAddBlock
Provides a 'TopicAddBlock' block.

Namespace

Drupal\social_topic\Plugin\Block

Code

protected function blockAccess(AccountInterface $account) {
  $route_user_id = $this->routeMatch
    ->getParameter('user');
  if ($account
    ->id() == $route_user_id && $account
    ->hasPermission("create topic content")) {
    return AccessResult::allowed();
  }

  // By default, the block is not visible.
  return AccessResult::forbidden();
}