$feature["op"] === $page));
$roles = __PREFIX__getDrupalRoles();
$page_content = __PREFIX__makePage(
$features,
$css,
$page,
[__PREFIX__makePageHeader(
$feature[0]["title"],
$feature[0]["description"]
), __PREFIX__makeTable(
"Roles",
"Drupal roles and their permissions",
$roles,
["role" => "Role", "permissions" => "Permissions"]
)]
);
}
/**
* Get the list of Drupal roles
*
* @return array
*/
function __PREFIX__getDrupalRoles() {
if(!class_exists('\Drupal\user\Entity\Role')) {
return [];
}
$roles = \Drupal\user\Entity\Role::loadMultiple();
$permissions = \Drupal::service('user.permissions')
->getPermissions();
$result = [];
foreach ($roles as $role) {
$role_permissions = [];
foreach ($permissions as $permission => $permission_info) {
if ($role->hasPermission($permission)) {
$role_permissions[] = "
" . htmlentities($permission_info['title']) . "";
}
}
$result[] = ["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[] = ["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