public function ContextAwarePluginTrait::getContextDefinition in Drupal 10
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Plugin/ContextAwarePluginTrait.php \Drupal\Core\Plugin\ContextAwarePluginTrait::getContextDefinition()
Return value
\Drupal\Core\Plugin\Context\ContextDefinitionInterface
File
- core/
lib/ Drupal/ Core/ Plugin/ ContextAwarePluginTrait.php, line 140
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));
}