function opigno_class_update_9001 in Opigno class 3.x
Set permissions for the content manager.
File
- ./
opigno_class.install, line 23 - Install, update and uninstall functions for the Opigno Class module.
Code
function opigno_class_update_9001() {
try {
$role = \Drupal::entityTypeManager()
->getStorage('user_role')
->load('content_manager');
} catch (PluginNotFoundException|InvalidPluginDefinitionException $e) {
watchdog_exception('opigno_class_exception', $e);
return;
}
if (!$role instanceof RoleInterface) {
return;
}
// Add permissions to manage the durations taxonomy to content manager.
$permissions = [
'create terms in duration',
'delete terms in duration',
'edit terms in duration',
];
foreach ($permissions as $permission) {
$role
->grantPermission($permission);
}
try {
$role
->save();
} catch (EntityStorageException $e) {
watchdog_exception('opigno_class_exception', $e);
}
}