You are here

public function GroupRole::grantAllPermissions in Group 2.0.x

Same name and namespace in other branches
  1. 8 src/Entity/GroupRole.php \Drupal\group\Entity\GroupRole::grantAllPermissions()

Grants all available permissions to the role.

Return value

\Drupal\group\Entity\GroupRoleInterface The group role this was called on.

Overrides GroupRoleInterface::grantAllPermissions

File

src/Entity/GroupRole.php, line 235

Class

GroupRole
Defines the Group role configuration entity.

Namespace

Drupal\group\Entity

Code

public function grantAllPermissions() {
  $permissions = $this
    ->getPermissionHandler()
    ->getPermissionsByGroupType($this
    ->getGroupType());
  foreach ($permissions as $permission => $info) {
    if (!in_array($this->audience, $info['allowed for'])) {
      unset($permissions[$permission]);
    }
  }
  return $this
    ->grantPermissions(array_keys($permissions));
}