public function KeycloakRoleMatcher::getRoleOptions in Keycloak OpenID Connect 8
Return all available user roles as options array.
Parameters
bool $exclude_locked: (Optional) Whether to exclude the system locked roles 'Anonymous' and 'Authenticated'. Defaults to TRUE.
Return value
array Array of user roles that can be used as select / radio / checkbox options.
1 call to KeycloakRoleMatcher::getRoleOptions()
- KeycloakRoleMatcher::applyRoleRules in src/
Service/ KeycloakRoleMatcher.php  - Applies user role rules to the given user account.
 
File
- src/
Service/ KeycloakRoleMatcher.php, line 298  
Class
- KeycloakRoleMatcher
 - Role matcher service.
 
Namespace
Drupal\keycloak\ServiceCode
public function getRoleOptions($exclude_locked = TRUE) {
  $role_options = [];
  $roles = Role::loadMultiple();
  foreach ($roles as $role) {
    $role_id = $role
      ->id();
    if ($exclude_locked && ($role_id == RoleInterface::ANONYMOUS_ID || $role_id == RoleInterface::AUTHENTICATED_ID)) {
      continue;
    }
    $role_options[$role_id] = $role
      ->label();
  }
  return $role_options;
}