user_permissions.install in User Permissions 8
Same filename and directory in other branches
Installation tasts for user_permissions.
File
user_permissions.installView source
<?php
/**
* @file
* Installation tasts for user_permissions.
*/
use Drupal\user\Entity\Role;
/**
* Creates a dummy role with no permissions.
*/
function user_permissions_install() {
// Creates a new role with the name $role_name.
$role = Role::create([
'id' => USER_PERMISSIONS_NO_ROLE,
'label' => USER_PERMISSIONS_NO_ROLE,
]);
$role
->save();
}
/**
* Removes any roles created by this module.
*/
function user_permissions_uninstall() {
foreach (user_roles() as $rid => $role) {
if (preg_match('/^_user_role_\\d+$/', $rid)) {
$role
->delete();
}
}
}
Functions
Name | Description |
---|---|
user_permissions_install | Creates a dummy role with no permissions. |
user_permissions_uninstall | Removes any roles created by this module. |