public function getMatchingContexts(array
$contexts, ContextDefinitionInterface
$definition) { return array_filter($contexts,
function DContextInterface
$context) use ($definition) { return $definition->
isSatisfiedBy($context);
});
} /**
* {@inheritdoc}
*/
public function applyContextMapping(ContextAwarePluginInterface
$plugin,
$contexts,
$mappings =
[]) { /** @var \Drupal\Core\Plugin\Context\ContextInterface[] $contexts */
$mappings +=
$plugin->
getContextMapping();
// Loop through each of the expected contexts.
$missing_value =
[];
foreach ($plugin->
getContextDefinitions() as $plugin_context_id =>
$plugin_context_definition) { // If this context was given a specific name, use that.
$context_id =
$mappings[$plugin_context_id] ??
$plugin_context_id;
if (!
empty($contexts[$context_id])) { // This assignment has been used, remove it.
unset($mappings[$plugin_context_id]);