interface ContextInterface in Drupal 9
Same name in this branch
- 9 core/lib/Drupal/Core/Plugin/Context/ContextInterface.php \Drupal\Core\Plugin\Context\ContextInterface
- 9 core/lib/Drupal/Component/Plugin/Context/ContextInterface.php \Drupal\Component\Plugin\Context\ContextInterface
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Plugin/Context/ContextInterface.php \Drupal\Core\Plugin\Context\ContextInterface
Context data and definitions for plugins supporting caching and return docs.
Hierarchy
- interface \Drupal\Component\Plugin\Context\ContextInterface; interface \Drupal\Core\Cache\CacheableDependencyInterface
- interface \Drupal\Core\Plugin\Context\ContextInterface
Expanded class hierarchy of ContextInterface
All classes that implement ContextInterface
See also
\Drupal\Component\Plugin\Context\ContextInterface
\Drupal\Core\Plugin\Context\ContextDefinitionInterface
3 files declare their use of ContextInterface
- ContextAwarePluginTrait.php in core/
lib/ Drupal/ Core/ Plugin/ ContextAwarePluginTrait.php - DefaultsSectionStorageTest.php in core/
modules/ layout_builder/ tests/ src/ Unit/ DefaultsSectionStorageTest.php - LayoutBuilderContextTrait.php in core/
modules/ layout_builder/ src/ Context/ LayoutBuilderContextTrait.php
File
- core/
lib/ Drupal/ Core/ Plugin/ Context/ ContextInterface.php, line 14
Namespace
Drupal\Core\Plugin\ContextView source
interface ContextInterface extends ComponentContextInterface, CacheableDependencyInterface {
/**
* {@inheritdoc}
*
* @return \Drupal\Core\Plugin\Context\ContextDefinitionInterface
*/
public function getContextDefinition();
/**
* Gets the context value as typed data object.
*
* @return \Drupal\Core\TypedData\TypedDataInterface
*/
public function getContextData();
/**
* 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.
*
* @param \Drupal\Core\Cache\CacheableDependencyInterface|mixed $dependency
* The dependency. If the object implements CacheableDependencyInterface,
* then its cacheability metadata will be used. Otherwise, the passed in
* object must be assumed to be uncacheable, so max-age 0 is set.
*
* @return $this
*
* @see \Drupal\Core\Cache\CacheableMetadata::createFromObject()
*/
public function addCacheableDependency($dependency);
/**
* Creates a new context with a different value.
*
* @param \Drupal\Core\Plugin\Context\ContextInterface $old_context
* The context object used to create a new object. Cacheability metadata
* will be copied over.
* @param mixed $value
* The value of the new context object.
*
* @return static
*/
public static function createFromContext(ContextInterface $old_context, $value);
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CacheableDependencyInterface:: |
public | function | The cache contexts associated with this object. | 34 |
CacheableDependencyInterface:: |
public | function | The maximum age for which this object may be cached. | 34 |
CacheableDependencyInterface:: |
public | function | The cache tags associated with this object. | 27 |
ContextInterface:: |
public | function | Adds a dependency on an object: merges its cacheability metadata. | 1 |
ContextInterface:: |
public static | function | Creates a new context with a different value. | 1 |
ContextInterface:: |
public | function | Gets a list of validation constraints. | 1 |
ContextInterface:: |
public | function | Gets the context value as typed data object. | 1 |
ContextInterface:: |
public | function |
Overrides ContextInterface:: |
|
ContextInterface:: |
public | function | Gets the context value. | 1 |
ContextInterface:: |
public | function | Returns whether the context has a value. | 1 |
ContextInterface:: |
public | function | Validates the set context value. | 1 |