You are here

public function AccessManager::managedRoles in Administer Users by Role 8.3

Returns a list of all roles that are available to be managed by this module.

Return value

\Drupal\user\RoleInterface[] An associative array with the role id as the key and the role object as value.

Overrides AccessManagerInterface::managedRoles

3 calls to AccessManager::managedRoles()
AccessManager::listRoles in src/Services/AccessManager.php
List all accessible roles for the specified operation.
AccessManager::permissions in src/Services/AccessManager.php
Return permissions to add.
AccessManager::rolesChanged in src/Services/AccessManager.php
Acts on changes to configured roles.

File

src/Services/AccessManager.php, line 142

Class

AccessManager
Access Manager.

Namespace

Drupal\administerusersbyrole\Services

Code

public function managedRoles() {
  $roles = array_filter(user_roles(TRUE), function ($role) {
    return !$role
      ->hasPermission('administer users');
  });
  unset($roles[AccountInterface::AUTHENTICATED_ROLE]);
  return $roles;
}