interface ContextInterface in Drupal 10
Same name in this branch
- 10 core/lib/Drupal/Core/Plugin/Context/ContextInterface.php \Drupal\Core\Plugin\Context\ContextInterface
- 10 core/lib/Drupal/Component/Plugin/Context/ContextInterface.php \Drupal\Component\Plugin\Context\ContextInterface
Same name and namespace in other branches
- 8 core/lib/Drupal/Component/Plugin/Context/ContextInterface.php \Drupal\Component\Plugin\Context\ContextInterface
- 9 core/lib/Drupal/Component/Plugin/Context/ContextInterface.php \Drupal\Component\Plugin\Context\ContextInterface
Provides data and definitions for plugins during runtime and administration.
Plugin contexts are satisfied by ContextInterface implementing objects. These objects always contain a definition of what data they will provide during runtime. During run time, ContextInterface implementing objects must also provide the corresponding data value.
Hierarchy
- interface \Drupal\Component\Plugin\Context\ContextInterface
Expanded class hierarchy of ContextInterface
All classes that implement ContextInterface
See also
\Drupal\Component\Plugin\Context\ContextDefinitionInterface
8 files declare their use of ContextInterface
- BlockComponentRenderArrayTest.php in core/
modules/ layout_builder/ tests/ src/ Unit/ BlockComponentRenderArrayTest.php - ConditionPluginCollection.php in core/
lib/ Drupal/ Core/ Condition/ ConditionPluginCollection.php - ContextAwarePluginInterface.php in core/
lib/ Drupal/ Component/ Plugin/ ContextAwarePluginInterface.php - ContextAwarePluginTrait.php in core/
lib/ Drupal/ Core/ Plugin/ ContextAwarePluginTrait.php - ContextAwarePluginTraitTest.php in core/
tests/ Drupal/ KernelTests/ Core/ Plugin/ Context/ ContextAwarePluginTraitTest.php
File
- core/
lib/ Drupal/ Component/ Plugin/ Context/ ContextInterface.php, line 15
Namespace
Drupal\Component\Plugin\ContextView source
interface ContextInterface {
/**
* Gets the context value.
*
* @return mixed
* The currently set context value, or NULL if it is not set.
*/
public function getContextValue();
/**
* Returns whether the context has a value.
*
* @return bool
* TRUE if the context has a value, FALSE otherwise.
*/
public function hasContextValue();
/**
* Gets the provided definition that the context must conform to.
*
* @return \Drupal\Component\Plugin\Context\ContextDefinitionInterface
* The defining characteristic representation of the context.
*/
public function getContextDefinition();
/**
* Gets a list of validation constraints.
*
* @return array
* Array of constraints, each being an instance of
* \Symfony\Component\Validator\Constraint.
*/
public function getConstraints();
/**
* Validates the set context value.
*
* @return \Symfony\Component\Validator\ConstraintViolationListInterface
* A list of constraint violations. If the list is empty, validation
* succeeded.
*/
public function validate();
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ContextInterface:: |
public | function | Gets a list of validation constraints. | 1 |
ContextInterface:: |
public | function | Gets the provided definition that the context must conform to. | 2 |
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 |