RoleStorage::isPermissionInRoles

public RoleStorage::isPermissionInRoles($permission, array $rids)

Returns whether a permission is in one of the passed in roles.

Parameters

string $permission: The permission.

array $rids: The list of role IDs to check.

Return value

bool TRUE is the permission is in at least one of the roles. FALSE otherwise.

Overrides RoleStorageInterface::isPermissionInRoles

File

core/modules/user/src/RoleStorage.php, line 15

Class

RoleStorage
Controller class for user roles.

Namespace

Drupal\user

Code

public function isPermissionInRoles($permission, array $rids) {
  $has_permission = FALSE;
  foreach ($this->loadMultiple($rids) as $role) {
    /** @var \Drupal\user\RoleInterface $role */
    if ($role->isAdmin() || $role->hasPermission($permission)) {
      $has_permission = TRUE;
      break;
    }
  }

  return $has_permission;
}
doc_Drupal
2016-10-29 09:38:57
Comments
Leave a Comment

Please login to continue.