You are here

function content_access_get_permission_access in Content Access 8

Same name and namespace in other branches
  1. 5 content_access.module \content_access_get_permission_access()
  2. 6 content_access.module \content_access_get_permission_access()
  3. 7 content_access.module \content_access_get_permission_access()

Returns an array of role ids that contain the given permission.

3 calls to content_access_get_permission_access()
ContentAccessRoleBasedFormTrait::disableCheckboxes in src/Form/ContentAccessRoleBasedFormTrait.php
Checkboxes access for content.
content_access_get_rids_per_node_op in ./content_access.module
Get rids per node.
content_access_get_setting_defaults in ./content_access.module
Defines default values for settings.

File

./content_access.module, line 293
Content access module file.

Code

function content_access_get_permission_access($perm, $reset = FALSE) {
  $roles =& drupal_static(__FUNCTION__, []);
  if ($reset) {
    $roles = [];
  }
  if (!isset($roles[$perm]) && $perm) {
    $user_roles = Role::loadMultiple();
    foreach ($user_roles as $role) {
      if ($role
        ->hasPermission($perm)) {
        $roles[$perm][] = $role
          ->id();
      }
    }
  }
  return isset($roles[$perm]) ? $roles[$perm] : [];
}