protected function UserRolesEventSubscriber::getRoleIds in SAML Authentication 4.x
Same name and namespace in other branches
- 8.3 modules/samlauth_user_roles/src/EventSubscriber/UserRolesEventSubscriber.php \Drupal\samlauth_user_roles\EventSubscriber\UserRolesEventSubscriber::getRoleIds()
Converts role machine names into role IDs; logs unknown names.
Parameters
array $role_names: The role machine names to convert.
\Drupal\user\Entity\Role[] $valid_roles_by_name: Array with all roles valid for this purpose.
string $config_log_name: Name to use for warning log if applicable.
1 call to UserRolesEventSubscriber::getRoleIds()
- UserRolesEventSubscriber::onUserSync in modules/
samlauth_user_roles/ src/ EventSubscriber/ UserRolesEventSubscriber.php - Assigns/unassigns roles as needed during user sync.
File
- modules/
samlauth_user_roles/ src/ EventSubscriber/ UserRolesEventSubscriber.php, line 240
Class
- UserRolesEventSubscriber
- Event subscriber for the samlauth_user_roles module.
Namespace
Drupal\samlauth_user_roles\EventSubscriberCode
protected function getRoleIds(array $role_names, array $valid_roles_by_name, $config_log_name) {
$role_ids = [];
foreach ($role_names as $role_name) {
if (isset($valid_roles_by_name[$role_name])) {
$role_ids[] = $valid_roles_by_name[$role_name]
->id();
}
else {
$this->logger
->warning('Unknown/invalid role %role in %name configuration value; skipping part of role (un)assignment.', [
'%name' => $config_log_name,
'%role' => $role_name,
]);
}
}
return $role_ids;
}