8.5.x ContextAwarePluginBase.php ContextAwarePluginBase::getContextDefinition($name)
8.5.x ContextAwarePluginBase.php ContextAwarePluginBase::getContextDefinition($name)
8.0.x ContextAwarePluginBase.php ContextAwarePluginBase::getContextDefinition($name)
8.0.x ContextAwarePluginBase.php ContextAwarePluginBase::getContextDefinition($name)
8.1.x ContextAwarePluginBase.php ContextAwarePluginBase::getContextDefinition($name)
8.1.x ContextAwarePluginBase.php ContextAwarePluginBase::getContextDefinition($name)
8.2.x ContextAwarePluginBase.php ContextAwarePluginBase::getContextDefinition($name)
8.2.x ContextAwarePluginBase.php ContextAwarePluginBase::getContextDefinition($name)
8.3.x ContextAwarePluginBase.php ContextAwarePluginBase::getContextDefinition($name)
8.3.x ContextAwarePluginBase.php ContextAwarePluginBase::getContextDefinition($name)
8.4.x ContextAwarePluginBase.php ContextAwarePluginBase::getContextDefinition($name)
8.4.x ContextAwarePluginBase.php ContextAwarePluginBase::getContextDefinition($name)
8.6.x ContextAwarePluginBase.php ContextAwarePluginBase::getContextDefinition($name)
8.6.x ContextAwarePluginBase.php ContextAwarePluginBase::getContextDefinition($name)

Gets a specific context definition of the plugin.

Parameters

string $name: The name of the context in the plugin definition.

Return value

\Drupal\Component\Plugin\Context\ContextDefinitionInterface The definition against which the context value must validate.

Throws

\Drupal\Component\Plugin\Exception\PluginException If the requested context is not defined.

Overrides ContextAwarePluginInterface::getContextDefinition

1 call to ContextAwarePluginBase::getContextDefinition()
ContextAwarePluginBase::createContextFromConfiguration in core/lib/Drupal/Component/Plugin/ContextAwarePluginBase.php
Creates context objects from any context mappings in configuration.
1 method overrides ContextAwarePluginBase::getContextDefinition()

File

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

Class

ContextAwarePluginBase
Base class for plugins that are context aware.

Namespace

Drupal\Component\Plugin

Code

public function getContextDefinition($name) {
  $definition = $this
    ->getPluginDefinition();
  if (empty($definition['context'][$name])) {
    throw new ContextException(sprintf("The %s context is not a valid context.", $name));
  }
  return $definition['context'][$name];
}