I need to get permissions for all user roles, which are used. The code looks something like this:
$anonymous = Role::load('anonymous');
$anonymousPermissions = $anonymous->getPermissions();
The code for anonymous (and also for authenticated) returns an array of permissions, but the same code for administrator returns null:
$administrator = Role::load('administrator');
How can I get permissions for the role Administrator? (The machine name of role Administrator is administrator and also in the database is nothing suspicious.)
I have tried also:
$administratorPermissions = user_role_permissions(['administrator']);
It returns:
array(1) {
["administrator"] =>
array(0) {
}
}
If I try:
$roles = Role::loadMultiple();
foreach ($roles as $role => $rolesObj) {
$role_list[$role] = $rolesObj->get('label');
}
print_r($role_list);
Then I get:
Array
(
[anonymous] => Anonymous user
[authenticated] => Authenticated user
)