You are here

public function ContextAwarePluginTrait::setContextMapping in Drupal 9

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 138

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;
}