public function ContextAwarePluginBase::__construct

Same name in this branch
  1. 8.x drupal/core/lib/Drupal/Core/Plugin/ContextAwarePluginBase.php \Drupal\Core\Plugin\ContextAwarePluginBase::__construct()
  2. 8.x drupal/core/lib/Drupal/Component/Plugin/ContextAwarePluginBase.php \Drupal\Component\Plugin\ContextAwarePluginBase::__construct()

Override of \Drupal\Component\Plugin\ContextAwarePluginBase::__construct().

Overrides ContextAwarePluginBase::__construct

File

drupal/core/lib/Drupal/Core/Plugin/ContextAwarePluginBase.php, line 27
Contains \Drupal\Core\Plugin\ContextAwarePluginBase

Class

ContextAwarePluginBase
Drupal specific class for plugins that use context.

Namespace

Drupal\Core\Plugin

Code

public function __construct(array $configuration, $plugin_id, array $plugin_definition) {
  $context = array();
  if (isset($configuration['context'])) {
    $context = $configuration['context'];
    unset($configuration['context']);
  }
  parent::__construct($configuration, $plugin_id, $plugin_definition);
  foreach ($context as $key => $value) {
    $context_definition = $this
      ->getContextDefinition($key);
    $this->context[$key] = new Context($context_definition);
    $this->context[$key]
      ->setContextValue($value);
  }
}