8.5.x ContextAwarePluginBase.php ContextAwarePluginBase::setContextMapping(array $context_mapping)
8.0.x ContextAwarePluginBase.php ContextAwarePluginBase::setContextMapping(array $context_mapping)
8.1.x ContextAwarePluginBase.php ContextAwarePluginBase::setContextMapping(array $context_mapping)
8.2.x ContextAwarePluginBase.php ContextAwarePluginBase::setContextMapping(array $context_mapping)
8.3.x ContextAwarePluginBase.php ContextAwarePluginBase::setContextMapping(array $context_mapping)
8.4.x ContextAwarePluginBase.php ContextAwarePluginBase::setContextMapping(array $context_mapping)
8.6.x ContextAwarePluginBase.php ContextAwarePluginBase::setContextMapping(array $context_mapping)

Sets a mapping of the expected assignment names to their context names.

Parameters

array $context_mapping: A mapping of the expected assignment names to their context names. For example, if one of the $contexts is named 'user.current_user', but the plugin expects a context named 'user', then this map would contain 'user' => 'user.current_user'.

Return value

$this

Overrides ContextAwarePluginInterface::setContextMapping

1 call to ContextAwarePluginBase::setContextMapping()
ConditionPluginBase::submitConfigurationForm in core/lib/Drupal/Core/Condition/ConditionPluginBase.php
Form submission handler.

File

core/lib/Drupal/Core/Plugin/ContextAwarePluginBase.php, line 88

Class

ContextAwarePluginBase
Base class for plugins that are context aware.

Namespace

Drupal\Core\Plugin

Code

public function setContextMapping(array $context_mapping) {
  if ($this instanceof ConfigurablePluginInterface) {
    $configuration = $this
      ->getConfiguration();
    $configuration['context_mapping'] = array_filter($context_mapping);
    $this
      ->setConfiguration($configuration);
  }
  else {
    $this->configuration['context_mapping'] = $context_mapping;
  }
  return $this;
}