You are here

public static function GroupAccessResult::allowedIfHasGroupPermission in Group 8

Same name and namespace in other branches
  1. 2.0.x src/Access/GroupAccessResult.php \Drupal\group\Access\GroupAccessResult::allowedIfHasGroupPermission()

Allows access if the permission is present, neutral otherwise.

@todo Keep an eye on the following with regard to using the current user:

Parameters

\Drupal\group\Entity\GroupInterface $group: The group for which to check a permission.

\Drupal\Core\Session\AccountInterface $account: The account for which to check a permission.

string $permission: The permission to check for.

Return value

\Drupal\Core\Access\AccessResult If the account has the permission, isAllowed() will be TRUE, otherwise isNeutral() will be TRUE.

7 calls to GroupAccessResult::allowedIfHasGroupPermission()
GroupAccessControlHandler::checkAccess in src/Entity/Access/GroupAccessControlHandler.php
Performs access checks.
GroupContentEnablerBase::createAccess in src/Plugin/GroupContentEnablerBase.php
Performs access check for the create operation.
GroupContentEnablerBase::createEntityAccess in src/Plugin/GroupContentEnablerBase.php
Performs access check for the create target entity operation.
GroupContentEnablerBase::deleteAccess in src/Plugin/GroupContentEnablerBase.php
Performs access check for the delete operation.
GroupContentEnablerBase::updateAccess in src/Plugin/GroupContentEnablerBase.php
Performs access check for the update operation.

... See full list

File

src/Access/GroupAccessResult.php, line 32

Class

GroupAccessResult
Extends the AccessResult class with group permission checks.

Namespace

Drupal\group\Access

Code

public static function allowedIfHasGroupPermission(GroupInterface $group, AccountInterface $account, $permission) {
  return static::allowedIf($group
    ->hasPermission($permission, $account))
    ->addCacheContexts([
    'user.group_permissions',
  ]);
}