You are here

protected function BookAddBlock::blockAccess in Open Social 10.1.x

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

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

Overrides BlockPluginTrait::blockAccess

File

modules/social_features/social_book/src/Plugin/Block/BookAddBlock.php, line 72

Class

BookAddBlock
Provides a 'BookAddBlock' block.

Namespace

Drupal\social_book\Plugin\Block

Code

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

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