function ContextAwarePluginTrait::setContext
Same name in other branches
- 9 core/lib/Drupal/Core/Plugin/ContextAwarePluginTrait.php \Drupal\Core\Plugin\ContextAwarePluginTrait::setContext()
- 10 core/lib/Drupal/Core/Plugin/ContextAwarePluginTrait.php \Drupal\Core\Plugin\ContextAwarePluginTrait::setContext()
2 calls to ContextAwarePluginTrait::setContext()
- ContextAwarePluginTrait::setContextValue in core/
lib/ Drupal/ Core/ Plugin/ ContextAwarePluginTrait.php - TestContextAwarePlugin::setContext in core/
tests/ Drupal/ KernelTests/ Core/ Plugin/ Context/ ContextAwarePluginTraitTest.php - Set a context on this plugin.
1 method overrides ContextAwarePluginTrait::setContext()
- DefaultsSectionStorage::setContext in core/
modules/ layout_builder/ src/ Plugin/ SectionStorage/ DefaultsSectionStorage.php
File
-
core/
lib/ Drupal/ Core/ Plugin/ ContextAwarePluginTrait.php, line 59
Class
- ContextAwarePluginTrait
- Provides a trait to add context-aware functionality to plugins.
Namespace
Drupal\Core\PluginCode
public function setContext($name, ComponentContextInterface $context) {
// Check that the context passed is an instance of our extended interface.
if (!$context instanceof ContextInterface) {
throw new ContextException("Passed {$name} context must be an instance of \\Drupal\\Core\\Plugin\\Context\\ContextInterface");
}
$this->context[$name] = $context;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.