function _opigno_moxtra_update_user_role in Opigno Moxtra 3.x
Add permissions to role.
2 calls to _opigno_moxtra_update_user_role()
- opigno_moxtra_update_9002 in ./
opigno_moxtra.install - Add permissions to administer ILT and LM.
- opigno_moxtra_update_9003 in ./
opigno_moxtra.install - Add permissions to collaborative_features role.
File
- ./
opigno_moxtra.install, line 131 - Install, update and uninstall functions for the Opigno Moxtra module.
Code
function _opigno_moxtra_update_user_role($role, $permissions) {
try {
$role = \Drupal::entityTypeManager()
->getStorage('user_role')
->load($role);
} catch (PluginNotFoundException|InvalidPluginDefinitionException $e) {
watchdog_exception('opigno_moxtra_exception', $e);
return;
}
if (!$role instanceof RoleInterface) {
return;
}
foreach ($permissions as $permission) {
$role
->grantPermission($permission);
}
try {
$role
->save();
} catch (EntityStorageException $e) {
watchdog_exception('opigno_moxtra_exception', $e);
}
}