interface ContextHandlerInterface
Same name in other branches
- 8.9.x core/lib/Drupal/Core/Plugin/Context/ContextHandlerInterface.php \Drupal\Core\Plugin\Context\ContextHandlerInterface
- 10 core/lib/Drupal/Core/Plugin/Context/ContextHandlerInterface.php \Drupal\Core\Plugin\Context\ContextHandlerInterface
- 11.x core/lib/Drupal/Core/Plugin/Context/ContextHandlerInterface.php \Drupal\Core\Plugin\Context\ContextHandlerInterface
Provides an interface for handling sets of contexts.
Hierarchy
- interface \Drupal\Core\Plugin\Context\ContextHandlerInterface
Expanded class hierarchy of ContextHandlerInterface
All classes that implement ContextHandlerInterface
8 files declare their use of ContextHandlerInterface
- BlockAccessControlHandler.php in core/
modules/ block/ src/ BlockAccessControlHandler.php - BlockComponentRenderArrayTest.php in core/
modules/ layout_builder/ tests/ src/ Unit/ BlockComponentRenderArrayTest.php - BlockRepository.php in core/
modules/ block/ src/ BlockRepository.php - FilteredPluginManagerTraitTest.php in core/
tests/ Drupal/ Tests/ Core/ Plugin/ FilteredPluginManagerTraitTest.php - SectionRenderTest.php in core/
modules/ layout_builder/ tests/ src/ Unit/ SectionRenderTest.php
File
-
core/
lib/ Drupal/ Core/ Plugin/ Context/ ContextHandlerInterface.php, line 10
Namespace
Drupal\Core\Plugin\ContextView source
interface ContextHandlerInterface {
/**
* Determines plugins whose constraints are satisfied by a set of contexts.
*
* @todo Use context definition objects after
* https://www.drupal.org/node/2281635.
*
* @param \Drupal\Component\Plugin\Context\ContextInterface[] $contexts
* An array of contexts.
* @param array $definitions
* An array of plugin definitions.
*
* @return array
* An array of plugin definitions.
*/
public function filterPluginDefinitionsByContexts(array $contexts, array $definitions);
/**
* Checks a set of requirements against a set of contexts.
*
* @todo Use context definition objects after
* https://www.drupal.org/node/2281635.
*
* @param \Drupal\Component\Plugin\Context\ContextInterface[] $contexts
* An array of available contexts.
* @param \Drupal\Core\TypedData\DataDefinitionInterface[] $requirements
* An array of requirements.
*
* @return bool
* TRUE if all of the requirements are satisfied by the context, FALSE
* otherwise.
*/
public function checkRequirements(array $contexts, array $requirements);
/**
* Determines which contexts satisfy the constraints of a given definition.
*
* @todo Use context definition objects after
* https://www.drupal.org/node/2281635.
*
* @param \Drupal\Component\Plugin\Context\ContextInterface[] $contexts
* An array of contexts.
* @param \Drupal\Core\Plugin\Context\ContextDefinitionInterface $definition
* The definition to satisfy.
*
* @return \Drupal\Component\Plugin\Context\ContextInterface[]
* An array of matching contexts.
*/
public function getMatchingContexts(array $contexts, ContextDefinitionInterface $definition);
/**
* Prepares a plugin for evaluation.
*
* @param \Drupal\Core\Plugin\ContextAwarePluginInterface $plugin
* A plugin about to be evaluated.
* @param \Drupal\Core\Plugin\Context\ContextInterface[] $contexts
* An array of contexts to set on the plugin. They will only be set if they
* match the plugin's context definitions.
* @param array $mappings
* (optional) A mapping of the expected assignment names to their context
* names. For example, if one of the $contexts is named 'current_user', but the
* plugin expects a context named 'user', then this map would contain
* 'user' => 'current_user'.
*
* @throws \Drupal\Component\Plugin\Exception\ContextException
* Thrown when a context assignment was not satisfied.
* @throws \Drupal\Component\Plugin\Exception\MissingValueContextException
* Thrown when a context is provided but has no value. Only thrown if
* no contexts are missing.
*/
public function applyContextMapping(ContextAwarePluginInterface $plugin, $contexts, $mappings = []);
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overrides |
---|---|---|---|---|
ContextHandlerInterface::applyContextMapping | public | function | Prepares a plugin for evaluation. | 1 |
ContextHandlerInterface::checkRequirements | public | function | Checks a set of requirements against a set of contexts. | 1 |
ContextHandlerInterface::filterPluginDefinitionsByContexts | public | function | Determines plugins whose constraints are satisfied by a set of contexts. | 1 |
ContextHandlerInterface::getMatchingContexts | public | function | Determines which contexts satisfy the constraints of a given definition. | 1 |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.