Drupal 8  8.0.2
BookNavigationCacheContext Class Reference
Inheritance diagram for BookNavigationCacheContext:

Public Member Functions

 __construct (RequestStack $request_stack)
 
 getContext ()
 
 getCacheableMetadata ()
 

Static Public Member Functions

static getLabel ()
 

Protected Attributes

 $requestStack
 

Detailed Description

Defines the book navigation cache context service.

Cache context ID: 'route.book_navigation'.

This allows for book navigation location-aware caching. It depends on:

  • whether the current route represents a book node at all
  • and if so, where in the book hierarchy we are

This class is container-aware to avoid initializing the 'book.manager' service when it is not necessary.

Constructor & Destructor Documentation

__construct ( RequestStack  $request_stack)

Constructs a new BookNavigationCacheContext service.

Parameters
\Symfony\Component\HttpFoundation\RequestStack$request_stackThe request stack.

References Drupal\requestStack().

Here is the call graph for this function:

Member Function Documentation

getCacheableMetadata ( )

{Gets the cacheability metadata for the context.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.
Returns
A cacheable metadata object.
}

Implements CacheContextInterface.

References Drupal\requestStack().

Here is the call graph for this function:

getContext ( )

{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.

Returns
string The string representation of the cache context.
}

Implements CacheContextInterface.

References Drupal\requestStack().

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.
}

Implements CacheContextInterface.

References t().

Here is the call graph for this function:


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