public function ContextAwarePluginBase::getContextDefinition in Service Container 7
Same name and namespace in other branches
- 7.2 lib/Drupal/Component/Plugin/ContextAwarePluginBase.php \Drupal\Component\Plugin\ContextAwarePluginBase::getContextDefinition()
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
3 calls to ContextAwarePluginBase::getContextDefinition()
- ContextAwarePluginBase::createContextFromConfiguration in lib/
Drupal/ Component/ Plugin/ ContextAwarePluginBase.php - Creates context objects from any context mappings in configuration.
- ContextAwarePluginBase::getContext in lib/
Drupal/ Component/ Plugin/ ContextAwarePluginBase.php - Gets a defined context.
- ContextAwarePluginBase::setContextValue in lib/
Drupal/ Component/ Plugin/ ContextAwarePluginBase.php - Sets the value for a defined context.
File
- lib/
Drupal/ Component/ Plugin/ ContextAwarePluginBase.php, line 81 - Contains \Drupal\Component\Plugin\ContextAwarePluginBase.
Class
- ContextAwarePluginBase
- Base class for plugins that are context aware.
Namespace
Drupal\Component\PluginCode
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];
}