Drupal 8  8.0.2
NodeAccessGrantsCacheContext Class Reference
Inheritance diagram for NodeAccessGrantsCacheContext:

Public Member Functions

 getContext ($operation=NULL)
 
 getCacheableMetadata ($operation=NULL)
 
- Public Member Functions inherited from UserCacheContextBase
 __construct (AccountInterface $user)
 

Static Public Member Functions

static getLabel ()
 

Protected Member Functions

 checkNodeGrants ($operation)
 

Additional Inherited Members

- Protected Attributes inherited from UserCacheContextBase
 $user
 

Detailed Description

Defines the node access view cache context service.

Cache context ID: 'user.node_grants' (to vary by all operations' grants). Calculated cache context ID: 'user.node_grants:operation', e.g. 'user.node_grants:view' (to vary by the view operation's grants).

This allows for node access grants-sensitive caching when listing nodes.

See Also
node_query_node_access_alter()

Member Function Documentation

checkNodeGrants (   $operation)
protected

Checks the node grants for the given operation.

Parameters
string$operationThe operation to check the node grants for.
Returns
string The string representation of the cache context.

Referenced by NodeAccessGrantsCacheContext\getContext().

Here is the caller graph for this function:

getCacheableMetadata (   $operation = NULL)

{Gets the cacheability metadata for the context based on the parameter value.There are three valid cases for the returned CacheableMetadata object:

  • An empty object means this can be optimized away safely.
  • A max-age of 0 means that this context can never be optimized away. It will never bubble up and cache tags will not be used.
  • Any non-zero max-age and cache tags will bubble up into the cache item if this is optimized away to allow for invalidation if the context value changes.
Parameters
string | null$parameterThe parameter, or NULL to indicate all possible parameter values.
Returns
A cacheable metadata object.
Exceptions
\LogicExceptionThrown if the passed in parameter is invalid.
}

Implements CalculatedCacheContextInterface.

References Drupal\moduleHandler().

Here is the call graph for this function:

getContext (   $operation = NULL)

{Returns the string representation of the cache context.A cache context service's name is used as a token (placeholder) cache key, and is then replaced with the string returned by this method.

Parameters
string | null$parameterThe parameter, or NULL to indicate all possible parameter values.
Returns
string The string representation of the cache context. When $parameter is NULL, a value representing all possible parameters must be generated.
Exceptions
\LogicExceptionThrown if the passed in parameter is invalid.
}

Implements CalculatedCacheContextInterface.

References NodeAccessGrantsCacheContext\checkNodeGrants().

Here is the call graph for this function:

static getLabel ( )
static

{Returns the label of the cache context.

Returns
string The label of the cache context.
See Also
Cache
}

Implements CalculatedCacheContextInterface.

References t().

Here is the call graph for this function:


The documentation for this class was generated from the following file: