Skip to content
Snippets Groups Projects
Commit 96265bc8 authored by Eric Bremner's avatar Eric Bremner Committed by Kevin Paxman
Browse files

ISTWCMS-4954: adding role creation and permission setting to install hook

parent b9f50792
No related branches found
No related tags found
1 merge request!133Feature/istwcms 4954 ebremner features
......@@ -10,11 +10,50 @@ use Drupal\node\Entity\Node;
use Drupal\uw_cfg_common\UwPermissions\UwPermissions;
use Drupal\user\Entity\Role;
use Drupal\Core\Config\FileStorage;
use Drupal\uw_cfg_common\UwRoles\UwRoles;
/**
* Implements hook_install().
*/
function uw_cfg_common_install() {
// Get the role ids for UW roles.
$uw_rids = UwRoles::getUwRoleIds();
// Step through each of the rids and create
// role and set permissions.
foreach ($uw_rids as $uw_rid) {
// Create the role.
$role = Role::create(
[
'id' => $uw_rid,
'label' => UwRoles::getUwRoleLabel($uw_rid),
]
);
$role->save();
// Get the info about the role.
$uw_role = UwRoles::getUwRole($uw_rid);
// Set the permissions for the role.
UwRoles::setUwPermissions($uw_role);
}
// Get the role ids for Drupal roles.
$drupal_rids = UwRoles::getDrupalRoleIds();
// Step through each of the Drupal roles and
// set the permissions.
foreach ($drupal_rids as $drupal_rid) {
// Get the info about the role.
$uw_role = UwRoles::getUwRole($drupal_rid);
// Set the permissions for the role.
UwRoles::setUwPermissions($uw_role);
}
$permissions_to_process = [
'Blog' => [
'Use content type' => [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment