function workflow_access_get_role_gid in Workflow 8
Helper providing numeric id for role. Copied from content_access.module.
2 calls to workflow_access_get_role_gid()
- workflow_access_node_access_records in modules/
workflow_access/ workflow_access.module - Implements hook_node_access_records().
- workflow_access_node_grants in modules/
workflow_access/ workflow_access.module - Implements hook_node_grants().
File
- modules/
workflow_access/ workflow_access.module, line 128 - Provides node access permissions based on workflow states.
Code
function workflow_access_get_role_gid($rid) {
// @todo D8: compare with content_access module.
// $config = \Drupal::configFactory()->getEditable('content_access.settings');
// $roles_gids = $config->get('content_access_roles_gids');
// return $roles_gids[$role];
//
// Return a weight, avoiding negative values by starting with 100.
// For 'Author', no role exists.
/** @var \Drupal\user\RoleInterface $role */
$role = Role::load($rid);
$weight = $role ? 100 + $role
->getWeight() : 100 - 20;
return $weight;
}