Drupal 8  8.0.2
LanguagesCacheContext Class Reference
Inheritance diagram for LanguagesCacheContext:

Public Member Functions

 __construct (LanguageManagerInterface $language_manager)
 
 getContext ($type=NULL)
 
 getCacheableMetadata ($type=NULL)
 

Static Public Member Functions

static getLabel ()
 

Protected Attributes

 $languageManager
 

Detailed Description

Defines the LanguagesCacheContext service, for "per language" caching.

Constructor & Destructor Documentation

__construct ( LanguageManagerInterface  $language_manager)

Constructs a new LanguagesCacheContext service.

Parameters
\Drupal\Core\Language\LanguageManagerInterface$language_managerThe language manager.

References Drupal\languageManager().

Here is the call graph for this function:

Member Function Documentation

getCacheableMetadata (   $type = 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.

getContext (   $type = 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.
}

$type can be NULL, or one of the language types supported by the language manager, typically:

  • LanguageInterface::TYPE_INTERFACE
  • LanguageInterface::TYPE_CONTENT
  • LanguageInterface::TYPE_URL
See Also
::getLanguageTypes()
Exceptions
\RuntimeExceptionIn case an invalid language type is specified.

Implements CalculatedCacheContextInterface.

References Drupal\languageManager().

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:

Field Documentation

$languageManager
protected

The language manager.

Parameters
\Drupal\Core\Language\LanguageManagerInterface$language_manager

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