public function ContextAwarePluginBase::getContext

Implements \Drupal\Component\Plugin\ContextAwarePluginInterface::getContext().

Overrides ContextAwarePluginInterface::getContext

File

drupal/core/lib/Drupal/Component/Plugin/ContextAwarePluginBase.php, line 93
Contains \Drupal\Component\Plugin\ContextAwarePluginBase

Class

ContextAwarePluginBase
Base class for plugins that are context aware.

Namespace

Drupal\Component\Plugin

Code

public function getContext($name) {

  // Check for a valid context definition.
  $this
    ->getContextDefinition($name);

  // Check for a valid context value.
  if (!isset($this->context[$name])) {
    throw new PluginException("The {$name} context is not yet set.");
  }
  return $this->context[$name];
}