Skip to content

Commit

Permalink
Merge pull request #566 from City-of-Helsinki/UHF-8848
Browse files Browse the repository at this point in the history
UHF-8848: Super administrator role
  • Loading branch information
tuutti authored Aug 23, 2023
2 parents c43b11c + 8245766 commit ab59ef5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
langcode: en
status: true
dependencies: { }
id: super_administrator
label: 'Super administrator'
weight: 7
is_admin: true
permissions: { }
24 changes: 24 additions & 0 deletions modules/helfi_user_roles/helfi_user_roles.install
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

declare(strict_types = 1);

use Drupal\user\Entity\Role;

/**
* Grants required permissions.
*/
Expand Down Expand Up @@ -47,3 +49,25 @@ function helfi_user_roles_install($is_syncing) : void {

helfi_user_roles_grant_permissions();
}

/**
* Install 'super_administrator' role.
*/
function helfi_user_roles_update_9001() : void {
if (Role::load('super_administrator')) {
return;
}
// We can't use 'update_helper' service to re-install configuration because
// it will re-install previously installed roles (from this module) and wipe
// out the permissions because 'user.role.*.yml' configuration files define
// no permissions.
// Permissions are granted by individual modules in hook_install().
Role::create([
'id' => 'super_administrator',
'label' => 'Super administrator',
'status' => TRUE,
'is_admin' => TRUE,
'weight' => 7,
])
->save();
}

0 comments on commit ab59ef5

Please sign in to comment.