You are here

protected function GroupCommentAccessControlHandler::getPermissionInGroups in Open Social 8.5

Same name and namespace in other branches
  1. 8.9 modules/custom/group_core_comments/src/GroupCommentAccessControlHandler.php \Drupal\group_core_comments\GroupCommentAccessControlHandler::getPermissionInGroups()
  2. 8 modules/custom/group_core_comments/src/GroupCommentAccessControlHandler.php \Drupal\group_core_comments\GroupCommentAccessControlHandler::getPermissionInGroups()
  3. 8.2 modules/custom/group_core_comments/src/GroupCommentAccessControlHandler.php \Drupal\group_core_comments\GroupCommentAccessControlHandler::getPermissionInGroups()
  4. 8.3 modules/custom/group_core_comments/src/GroupCommentAccessControlHandler.php \Drupal\group_core_comments\GroupCommentAccessControlHandler::getPermissionInGroups()
  5. 8.4 modules/custom/group_core_comments/src/GroupCommentAccessControlHandler.php \Drupal\group_core_comments\GroupCommentAccessControlHandler::getPermissionInGroups()
  6. 8.6 modules/custom/group_core_comments/src/GroupCommentAccessControlHandler.php \Drupal\group_core_comments\GroupCommentAccessControlHandler::getPermissionInGroups()
  7. 8.7 modules/custom/group_core_comments/src/GroupCommentAccessControlHandler.php \Drupal\group_core_comments\GroupCommentAccessControlHandler::getPermissionInGroups()
  8. 8.8 modules/custom/group_core_comments/src/GroupCommentAccessControlHandler.php \Drupal\group_core_comments\GroupCommentAccessControlHandler::getPermissionInGroups()
  9. 10.3.x modules/custom/group_core_comments/src/GroupCommentAccessControlHandler.php \Drupal\group_core_comments\GroupCommentAccessControlHandler::getPermissionInGroups()
  10. 10.0.x modules/custom/group_core_comments/src/GroupCommentAccessControlHandler.php \Drupal\group_core_comments\GroupCommentAccessControlHandler::getPermissionInGroups()
  11. 10.1.x modules/custom/group_core_comments/src/GroupCommentAccessControlHandler.php \Drupal\group_core_comments\GroupCommentAccessControlHandler::getPermissionInGroups()
  12. 10.2.x modules/custom/group_core_comments/src/GroupCommentAccessControlHandler.php \Drupal\group_core_comments\GroupCommentAccessControlHandler::getPermissionInGroups()

Checks if account was granted permission in group.

1 call to GroupCommentAccessControlHandler::getPermissionInGroups()
GroupCommentAccessControlHandler::checkAccess in modules/custom/group_core_comments/src/GroupCommentAccessControlHandler.php
Performs access checks.

File

modules/custom/group_core_comments/src/GroupCommentAccessControlHandler.php, line 69

Class

GroupCommentAccessControlHandler
Defines the access control handler for the comment entity type.

Namespace

Drupal\group_core_comments

Code

protected function getPermissionInGroups($perm, AccountInterface $account, $group_contents) {

  // Only when you have permission to view the comments.
  foreach ($group_contents as $group_content) {

    /** @var \Drupal\group\Entity\GroupContent $group_content */
    $group = $group_content
      ->getGroup();

    /** @var \Drupal\group\Entity\Group $group */
    if ($group
      ->hasPermission($perm, $account)) {
      return AccessResult::allowed()
        ->cachePerUser();
    }
  }

  // Fallback.
  return AccessResult::forbidden()
    ->cachePerUser();
}