You are here

public function OgMembership::hasPermission in Organic groups 8

Checks if the user has a permission inside the group.

Parameters

string $permission: The name of the permission.

Return value

bool TRUE if the user has permission.

Overrides OgMembershipInterface::hasPermission

File

src/Entity/OgMembership.php, line 356

Class

OgMembership
The membership entity that connects a group and a user.

Namespace

Drupal\og\Entity

Code

public function hasPermission(string $permission) : bool {

  // Blocked users do not have any permissions.
  if ($this
    ->isBlocked()) {
    return FALSE;
  }
  return (bool) array_filter($this
    ->getRoles(), function (OgRole $role) use ($permission) {
    return $role
      ->hasPermission($permission);
  });
}