diff --git a/core/lib/Drupal/Component/Plugin/Context/Context.php b/core/lib/Drupal/Component/Plugin/Context/Context.php index 932cd67..c3c9f20 100644 --- a/core/lib/Drupal/Component/Plugin/Context/Context.php +++ b/core/lib/Drupal/Component/Plugin/Context/Context.php @@ -25,7 +25,6 @@ class Context implements ContextInterface { * The class name or an array definition to which a context must conform. * * @var string|array - * A string or array. */ protected $contextDefinition; diff --git a/core/lib/Drupal/Component/Plugin/ContextAwarePluginBase.php b/core/lib/Drupal/Component/Plugin/ContextAwarePluginBase.php index 00054ec..ebf56ea 100644 --- a/core/lib/Drupal/Component/Plugin/ContextAwarePluginBase.php +++ b/core/lib/Drupal/Component/Plugin/ContextAwarePluginBase.php @@ -16,6 +16,13 @@ abstract class ContextAwarePluginBase extends PluginBase implements ContextAwarePluginInterface { /** + * The data objects representing the context of this plugin. + * + * @var array + */ + protected $context; + + /** * Implements \Drupal\Component\Plugin\ContextAwarePluginInterface::getContextDefinitions(). */ public function getContextDefinitions() { @@ -43,15 +50,15 @@ public function getContexts() { if (empty($definition['context'])) { return array(); } - if (empty($this->configuration['context'])) { + if (empty($this->context)) { throw new PluginException("There are no set contexts."); } $contexts = array(); foreach (array_keys($definition['context']) as $key) { - if (empty($this->configuration['context'][$key])) { + if (empty($this->context[$key])) { throw new PluginException("The $key context is not yet set."); } - $contexts[$key] = $this->configuration['context'][$key]; + $contexts[$key] = $this->context[$key]; } return $contexts; } @@ -64,11 +71,11 @@ public function getContext($key) { if (empty($definition['context'][$key])) { throw new PluginException("The $key context is not a valid context."); } - if (empty($this->configuration['context'][$key])) { + if (empty($this->context[$key])) { throw new PluginException("The $key context is not yet set."); } - return $this->configuration['context'][$key]; + return $this->context[$key]; } /** @@ -94,8 +101,8 @@ public function getContextValue($key) { */ public function setContextValue($key, $value) { $context_definition = $this->getContextDefinition($key); - $this->configuration['context'][$key] = new Context($context_definition); - $this->configuration['context'][$key]->setContextValue($value); + $this->context[$key] = new Context($context_definition); + $this->context[$key]->setContextValue($value); return $this; } diff --git a/core/lib/Drupal/Core/Plugin/ContextAwarePluginBase.php b/core/lib/Drupal/Core/Plugin/ContextAwarePluginBase.php index 35bba53..028befd 100644 --- a/core/lib/Drupal/Core/Plugin/ContextAwarePluginBase.php +++ b/core/lib/Drupal/Core/Plugin/ContextAwarePluginBase.php @@ -24,8 +24,8 @@ */ public function setContextValue($key, $value) { $context_definition = $this->getContextDefinition($key); - $this->configuration['context'][$key] = new Context($context_definition); - $this->configuration['context'][$key]->setContextValue($value); + $this->context[$key] = new Context($context_definition); + $this->context[$key]->setContextValue($value); return $this; }