You are here

public function GroupAddEventBlock::blockAccess in Open Social 8.8

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

Custom access logic to display the block.

Overrides BlockPluginTrait::blockAccess

File

modules/social_features/social_group/src/Plugin/Block/GroupAddEventBlock.php, line 26

Class

GroupAddEventBlock
Provides a 'GroupAddEventBlock' block.

Namespace

Drupal\social_group\Plugin\Block

Code

public function blockAccess(AccountInterface $account) {
  $group = _social_group_get_current_group();
  if (is_object($group)) {
    if ($group
      ->hasPermission('create group_node:event entity', $account) && $account
      ->hasPermission("create event 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();
}