protected function EntityExtraFieldContextTrait::applyPluginRuntimeContexts in Entity Extra Field 2.0.x
Apply the plugin runtime contexts.
Parameters
\Drupal\Core\Plugin\ContextAwarePluginInterface $plugin: The plugin instance.
array $contexts: An array of contexts that are not provided by the \Drupal\Core\Plugin\Context\ContextRepositoryInterface::getAvailableContexts() method.
Throws
\Drupal\Component\Plugin\Exception\ContextException
\Drupal\Component\Plugin\Exception\MissingValueContextException
2 calls to EntityExtraFieldContextTrait::applyPluginRuntimeContexts()
- EntityExtraField::hasConditionsBeenMet in src/
Entity/ EntityExtraField.php - Has extra field conditions been met.
- ExtraFieldBlockPlugin::build in src/
Plugin/ ExtraFieldType/ ExtraFieldBlockPlugin.php - Build the render array of the extra field type contents.
File
- src/
EntityExtraFieldContextTrait.php, line 27
Class
- EntityExtraFieldContextTrait
- Define the entity extra field context trait.
Namespace
Drupal\entity_extra_fieldCode
protected function applyPluginRuntimeContexts(ContextAwarePluginInterface $plugin, array $contexts = []) : void {
$context_repository = $this
->getContextRepository();
$current_contexts = $context_repository
->getAvailableContexts();
$context_ids = array_keys($current_contexts);
$runtime_context_ids = array_values(array_filter($context_ids, static function ($context_id) {
return strpos($context_id, '@') === 0;
}));
$contexts += $context_repository
->getRuntimeContexts($runtime_context_ids);
$contexts += array_intersect_key($current_contexts, array_flip(array_diff($context_ids, $runtime_context_ids)));
$this
->getContextHandler()
->applyContextMapping($plugin, $contexts);
}