function content_access_get_rids_per_node_op in Content Access 8
Same name and namespace in other branches
- 6 content_access.module \content_access_get_rids_per_node_op()
- 7 content_access.module \content_access_get_rids_per_node_op()
Get rids per node.
Returns optimized role ids for the given operation and node to grant access for.
If to a role access is granted by permissions, it's not necessary to write a grant for it. So it won't be returned.
Parameters
string $op: One of the supported operations.
\Drupal\node\NodeInterface $node: The node object.
1 call to content_access_get_rids_per_node_op()
- content_access_node_access_records in ./
content_access.module - Implements hook_node_access_records().
File
- ./
content_access.module, line 435 - Content access module file.
Code
function content_access_get_rids_per_node_op($op, NodeInterface $node) {
$rids = content_access_per_node_setting($op, $node);
if ($permission = content_access_get_permission_by_op($op, $node
->getType())) {
$perm_roles = content_access_get_permission_access($permission);
$rids = array_diff($rids, $perm_roles);
if (in_array(AccountInterface::AUTHENTICATED_ROLE, $perm_roles)) {
if (in_array(AccountInterface::ANONYMOUS_ROLE, $rids)) {
return [
AccountInterface::ANONYMOUS_ROLE,
AccountInterface::AUTHENTICATED_ROLE,
];
}
else {
return [
AccountInterface::AUTHENTICATED_ROLE,
];
}
}
}
return $rids;
}