"Role",
"permissions" => "Permissions",
)
),
)
);
}
/**
* Get the list of Drupal roles
*
* @return array
*/
function __PREFIX__getDrupalRoles() {
if(!class_exists('\Drupal\user\Entity\Role')) {
return array();
}
$roles = \Drupal\user\Entity\Role::loadMultiple();
$permissions = \Drupal::service('user.permissions')
->getPermissions();
$result = array();
foreach ($roles as $role) {
$role_permissions = array();
foreach ($permissions as $permission => $permission_info) {
if ($role->hasPermission($permission)) {
$role_permissions[] = "
" . htmlentities($permission_info['title']) . "";
}
}
$result[] = array(
"id" => $role->id(),
"role" => $role->label(),
"permissions" => "" . implode("", $role_permissions) . "
",
);
}
return $result;
}
/**
* Hook the features to add the login feature
*
* @param $features array{title: string, description: string, svg: string, hidden?: bool, op: string}[] The features
* container
*
* @return void
*/
function __PREFIX__checkDrupalRolesHooksFeatures(&$features) {
global $CHECK_DRUPAL_USER_ROLES;
$features[] = array(
"title" => "List Drupal roles",
"description" => "List all Drupal roles and their permissions.",
"svg" => '',
"op" => $CHECK_DRUPAL_USER_ROLES,
);
}
// section.functions.end
// section.hooks
add_hook("features", "__PREFIX__checkDrupalRolesHooksFeatures");
add_named_hook("GET_page", $CHECK_DRUPAL_USER_ROLES, "__PREFIX__makeCheckDrupalRolesPage");
// section.hooks.end