ContextInterface
interface ContextInterface implements ContextInterface, CacheableDependencyInterface (View source)
Context data and definitions for plugins supporting caching and return docs.
Methods
Gets the provided definition that the context must conform to.
The cache contexts associated with this object.
The cache tags associated with this object.
The maximum age for which this object may be cached.
Gets the context value as typed data object.
Adds a dependency on an object: merges its cacheability metadata.
Creates a new context with a different value.
Details
mixed
getContextValue()
Gets the context value.
bool
hasContextValue()
Returns whether the context has a value.
ContextDefinitionInterface
getContextDefinition()
Gets the provided definition that the context must conform to.
array
getConstraints()
Gets a list of validation constraints.
ConstraintViolationListInterface
validate()
Validates the set context value.
string[]
getCacheContexts()
The cache contexts associated with this object.
These identify a specific variation/representation of the object.
Cache contexts are tokens: placeholders that are converted to cache keys by the @cache_contexts_manager service. The replacement value depends on the request context (the current URL, language, and so on). They're converted before storing an object in cache.
string[]
getCacheTags()
The cache tags associated with this object.
When this object is modified, these cache tags will be invalidated.
int
getCacheMaxAge()
The maximum age for which this object may be cached.
TypedDataInterface
getContextData()
Gets the context value as typed data object.
$this
addCacheableDependency(CacheableDependencyInterface|mixed $dependency)
Adds a dependency on an object: merges its cacheability metadata.
For example, when a context depends on some configuration, an entity, or an access result, we must make sure their cacheability metadata is present on the response. This method makes doing that simple.
static ContextInterface
createFromContext(ContextInterface $old_context, mixed $value)
Creates a new context with a different value.