function parse_roles in LTI Tool Provider 2.x
Same name and namespace in other branches
- 8 lti_tool_provider.module \parse_roles()
Utility function to get an array of fully qualified LTI user roles.
Parameters
mixed $roles: Comma-separated list of roles or array of roles.
Return value
array An array of roles
2 calls to parse_roles()
- LtiToolProviderProvisionEventSubscriber::onCreateProvision in modules/
lti_tool_provider_provision/ src/ EventSubscriber/ LtiToolProviderProvisionEventSubscriber.php - LtiToolProviderRolesEventSubscriber::onAuthenticated in modules/
lti_tool_provider_roles/ src/ EventSubscriber/ LtiToolProviderRolesEventSubscriber.php
File
- ./
lti_tool_provider.module, line 63 - LTI Tool Provider hook implementations and support functions.
Code
function parse_roles($roles) : array {
$parsedRoles = [];
if (!is_array($roles)) {
$roles = explode(',', $roles);
}
foreach ($roles as $role) {
$role = trim($role);
if (!empty($role)) {
if (substr($role, 0, 4) !== 'urn:') {
$role = 'urn:lti:role:ims/lis/' . $role;
}
$parsedRoles[] = $role;
}
}
return $parsedRoles;
}