function ContextHandlerInterface::applyContextMapping

Same name in other branches
  1. 9 core/lib/Drupal/Core/Plugin/Context/ContextHandlerInterface.php \Drupal\Core\Plugin\Context\ContextHandlerInterface::applyContextMapping()
  2. 8.9.x core/lib/Drupal/Core/Plugin/Context/ContextHandlerInterface.php \Drupal\Core\Plugin\Context\ContextHandlerInterface::applyContextMapping()
  3. 10 core/lib/Drupal/Core/Plugin/Context/ContextHandlerInterface.php \Drupal\Core\Plugin\Context\ContextHandlerInterface::applyContextMapping()

Prepares a plugin for evaluation.

Parameters

\Drupal\Core\Plugin\ContextAwarePluginInterface $plugin: A plugin about to be evaluated.

\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.

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.

\Drupal\Component\Plugin\Exception\MissingValueContextException Thrown when a context is provided but has no value. Only thrown if no contexts are missing.

1 method overrides ContextHandlerInterface::applyContextMapping()
ContextHandler::applyContextMapping in core/lib/Drupal/Core/Plugin/Context/ContextHandler.php
Prepares a plugin for evaluation.

File

core/lib/Drupal/Core/Plugin/Context/ContextHandlerInterface.php, line 81

Class

ContextHandlerInterface
Provides an interface for handling sets of contexts.

Namespace

Drupal\Core\Plugin\Context

Code

public function applyContextMapping(ContextAwarePluginInterface $plugin, $contexts, $mappings = []);

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.