function ContextAwarePluginTrait::getContextDefinition
Same name in other branches
- 10 core/lib/Drupal/Core/Plugin/ContextAwarePluginTrait.php \Drupal\Core\Plugin\ContextAwarePluginTrait::getContextDefinition()
- 11.x core/lib/Drupal/Core/Plugin/ContextAwarePluginTrait.php \Drupal\Core\Plugin\ContextAwarePluginTrait::getContextDefinition()
Return value
\Drupal\Core\Plugin\Context\ContextDefinitionInterface
2 calls to ContextAwarePluginTrait::getContextDefinition()
- ContextAwarePluginBase::createContextFromConfiguration in core/
lib/ Drupal/ Core/ Plugin/ ContextAwarePluginBase.php - ContextAwarePluginTrait::getContext in core/
lib/ Drupal/ Core/ Plugin/ ContextAwarePluginTrait.php
File
-
core/
lib/ Drupal/ Core/ Plugin/ ContextAwarePluginTrait.php, line 174
Class
- ContextAwarePluginTrait
- Provides a trait to add context-aware functionality to plugins.
Namespace
Drupal\Core\PluginCode
public function getContextDefinition($name) {
$definition = $this->getPluginDefinition();
if ($definition instanceof ContextAwarePluginDefinitionInterface) {
if ($definition->hasContextDefinition($name)) {
return $definition->getContextDefinition($name);
}
}
elseif (!empty($definition['context_definitions'][$name])) {
return $definition['context_definitions'][$name];
}
throw new ContextException(sprintf("The %s context is not a valid context.", $name));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.