function ContextAwarePluginBase::createContextFromConfiguration

Same name in this branch
  1. 8.9.x core/lib/Drupal/Core/Plugin/ContextAwarePluginBase.php \Drupal\Core\Plugin\ContextAwarePluginBase::createContextFromConfiguration()
Same name in other branches
  1. 9 core/lib/Drupal/Core/Plugin/ContextAwarePluginBase.php \Drupal\Core\Plugin\ContextAwarePluginBase::createContextFromConfiguration()
  2. 9 core/lib/Drupal/Component/Plugin/ContextAwarePluginBase.php \Drupal\Component\Plugin\ContextAwarePluginBase::createContextFromConfiguration()

Creates context objects from any context mappings in configuration.

Parameters

array $context_configuration: An associative array of context names and values.

Return value

\Drupal\Component\Plugin\Context\ContextInterface[] An array of context objects.

1 call to ContextAwarePluginBase::createContextFromConfiguration()
ContextAwarePluginBase::__construct in core/lib/Drupal/Component/Plugin/ContextAwarePluginBase.php
Overrides \Drupal\Component\Plugin\PluginBase::__construct().
1 method overrides ContextAwarePluginBase::createContextFromConfiguration()
ContextAwarePluginBase::createContextFromConfiguration in core/lib/Drupal/Core/Plugin/ContextAwarePluginBase.php

File

core/lib/Drupal/Component/Plugin/ContextAwarePluginBase.php, line 83

Class

ContextAwarePluginBase
Base class for plugins that are context aware.

Namespace

Drupal\Component\Plugin

Code

protected function createContextFromConfiguration(array $context_configuration) {
    $contexts = [];
    foreach ($context_configuration as $key => $value) {
        $context_definition = $this->getContextDefinition($key);
        $contexts[$key] = new Context($context_definition, $value);
    }
    return $contexts;
}

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