function ContextAwarePluginTrait::setContextMapping

Same name in other branches
  1. 9 core/lib/Drupal/Core/Plugin/ContextAwarePluginTrait.php \Drupal\Core\Plugin\ContextAwarePluginTrait::setContextMapping()
  2. 11.x core/lib/Drupal/Core/Plugin/ContextAwarePluginTrait.php \Drupal\Core\Plugin\ContextAwarePluginTrait::setContextMapping()
1 call to ContextAwarePluginTrait::setContextMapping()
ConditionPluginBase::submitConfigurationForm in core/lib/Drupal/Core/Condition/ConditionPluginBase.php
Form submission handler.

File

core/lib/Drupal/Core/Plugin/ContextAwarePluginTrait.php, line 104

Class

ContextAwarePluginTrait
Provides a trait to add context-aware functionality to plugins.

Namespace

Drupal\Core\Plugin

Code

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

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