public function GroupAddBookBlock::blockAccess in Open Social 8.5
Same name and namespace in other branches
- 8.9 modules/social_features/social_book/src/Plugin/Block/GroupAddBookBlock.php \Drupal\social_book\Plugin\Block\GroupAddBookBlock::blockAccess()
- 8.3 modules/social_features/social_book/src/Plugin/Block/GroupAddBookBlock.php \Drupal\social_book\Plugin\Block\GroupAddBookBlock::blockAccess()
- 8.4 modules/social_features/social_book/src/Plugin/Block/GroupAddBookBlock.php \Drupal\social_book\Plugin\Block\GroupAddBookBlock::blockAccess()
- 8.6 modules/social_features/social_book/src/Plugin/Block/GroupAddBookBlock.php \Drupal\social_book\Plugin\Block\GroupAddBookBlock::blockAccess()
- 8.7 modules/social_features/social_book/src/Plugin/Block/GroupAddBookBlock.php \Drupal\social_book\Plugin\Block\GroupAddBookBlock::blockAccess()
- 8.8 modules/social_features/social_book/src/Plugin/Block/GroupAddBookBlock.php \Drupal\social_book\Plugin\Block\GroupAddBookBlock::blockAccess()
- 10.3.x modules/social_features/social_book/src/Plugin/Block/GroupAddBookBlock.php \Drupal\social_book\Plugin\Block\GroupAddBookBlock::blockAccess()
- 10.0.x modules/social_features/social_book/src/Plugin/Block/GroupAddBookBlock.php \Drupal\social_book\Plugin\Block\GroupAddBookBlock::blockAccess()
- 10.1.x modules/social_features/social_book/src/Plugin/Block/GroupAddBookBlock.php \Drupal\social_book\Plugin\Block\GroupAddBookBlock::blockAccess()
- 10.2.x modules/social_features/social_book/src/Plugin/Block/GroupAddBookBlock.php \Drupal\social_book\Plugin\Block\GroupAddBookBlock::blockAccess()
Custom access logic to display the block.
Overrides BlockPluginTrait::blockAccess
File
- modules/
social_features/ social_book/ src/ Plugin/ Block/ GroupAddBookBlock.php, line 33
Class
- GroupAddBookBlock
- Provides a 'GroupAddBookBlock' block.
Namespace
Drupal\social_book\Plugin\BlockCode
public function blockAccess(AccountInterface $account) {
if (\Drupal::moduleHandler()
->moduleExists('social_group')) {
$group = _social_group_get_current_group();
}
else {
$group = NULL;
}
if (is_object($group)) {
if ($group
->hasPermission('create group_node:book entity', $account) && $account
->hasPermission("create book content")) {
if ($group
->getGroupType()
->id() === 'public_group') {
$config = \Drupal::config('entity_access_by_field.settings');
if ($config
->get('disable_public_visibility') === 1 && !$account
->hasPermission('override disabled public visibility')) {
return AccessResult::forbidden();
}
}
return AccessResult::allowed();
}
}
// By default, the block is not visible.
return AccessResult::forbidden();
}