protected function NodeAccessGrantsCacheContext::checkNodeGrants in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/node/src/Cache/NodeAccessGrantsCacheContext.php \Drupal\node\Cache\NodeAccessGrantsCacheContext::checkNodeGrants()
Checks the node grants for the given operation.
Parameters
string $operation: The operation to check the node grants for.
Return value
string The string representation of the cache context.
1 call to NodeAccessGrantsCacheContext::checkNodeGrants()
- NodeAccessGrantsCacheContext::getContext in core/
modules/ node/ src/ Cache/ NodeAccessGrantsCacheContext.php - Returns the string representation of the cache context.
File
- core/
modules/ node/ src/ Cache/ NodeAccessGrantsCacheContext.php, line 68 - Contains \Drupal\node\Cache\NodeAccessGrantsCacheContext.
Class
- NodeAccessGrantsCacheContext
- Defines the node access view cache context service.
Namespace
Drupal\node\CacheCode
protected function checkNodeGrants($operation) {
// When checking the grants for the 'view' operation and the current user
// has a global view grant (i.e. a view grant for node ID 0) — note that
// this is automatically the case if no node access modules exist (no
// hook_node_grants() implementations) then we don't need to determine the
// exact node view grants for the current user.
if ($operation === 'view' && node_access_view_all_nodes($this->user)) {
return 'view.all';
}
$grants = node_access_grants($operation, $this->user);
$grants_context_parts = [];
foreach ($grants as $realm => $gids) {
$grants_context_parts[] = $realm . ':' . implode(',', $gids);
}
return $operation . '.' . implode(';', $grants_context_parts);
}