Overrides \Drupal\Component\Plugin\PluginBase::__construct().
Overrides the construction of context aware plugins to allow for unvalidated constructor based injection of contexts.
array $configuration: The plugin configuration, i.e. an array with configuration values keyed by configuration option name. The special key 'context' may be used to initialize the defined contexts by setting it to an array of context values keyed by context names.
Overrides PluginBase::__construct
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);
}
}