function user_role_permissions

Same name and namespace in other branches
  1. 7.x modules/user/user.module \user_role_permissions()
  2. 9 core/modules/user/user.module \user_role_permissions()
  3. 8.9.x core/modules/user/user.module \user_role_permissions()

Determine the permissions for one or more roles.

Parameters

array $roles: An array of role IDs.

Return value

array An array indexed by role ID. Each value is an array of permission strings for the given role.

Deprecated

in drupal:10.1.0 and is removed from drupal:11.0.0. There is no replacement beyond loading the roles and calling \Drupal\user\Entity\Role::getPermissions().

See also

https://www.drupal.org/node/3348138

1 call to user_role_permissions()
LegacyUserTest::testUserRolePermissions in core/modules/user/tests/src/Kernel/LegacyUserTest.php
Tests deprecation of user_role_permissions().

File

core/modules/user/user.module, line 238

Code

function user_role_permissions(array $roles) {
    @trigger_error(__FUNCTION__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no replacement beyond loading the roles and calling \\Drupal\\user\\Entity\\Role::getPermissions(). See https://www.drupal.org/node/3348138', E_USER_DEPRECATED);
    if (defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'update') {
        return _user_role_permissions_update($roles);
    }
    $entities = Role::loadMultiple($roles);
    $role_permissions = [];
    foreach ($roles as $rid) {
        $role_permissions[$rid] = isset($entities[$rid]) ? $entities[$rid]->getPermissions() : [];
    }
    return $role_permissions;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.