trait ContextAwarePluginManagerTrait in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Plugin/Context/ContextAwarePluginManagerTrait.php \Drupal\Core\Plugin\Context\ContextAwarePluginManagerTrait
Provides a trait for plugin managers that support context-aware plugins.
Hierarchy
- trait \Drupal\Core\Plugin\Context\ContextAwarePluginManagerTrait
1 file declares its use of ContextAwarePluginManagerTrait
- FilteredPluginManagerTrait.php in core/
lib/ Drupal/ Core/ Plugin/ FilteredPluginManagerTrait.php
File
- core/
lib/ Drupal/ Core/ Plugin/ Context/ ContextAwarePluginManagerTrait.php, line 8
Namespace
Drupal\Core\Plugin\ContextView source
trait ContextAwarePluginManagerTrait {
/**
* Wraps the context handler.
*
* @return \Drupal\Core\Plugin\Context\ContextHandlerInterface
*/
protected function contextHandler() {
return \Drupal::service('context.handler');
}
/**
* See \Drupal\Core\Plugin\Context\ContextAwarePluginManagerInterface::getDefinitionsForContexts().
*/
public function getDefinitionsForContexts(array $contexts = []) {
return $this
->contextHandler()
->filterPluginDefinitionsByContexts($contexts, $this
->getDefinitions());
}
/**
* See \Drupal\Component\Plugin\Discovery\DiscoveryInterface::getDefinitions().
*/
public abstract function getDefinitions();
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ContextAwarePluginManagerTrait:: |
protected | function | Wraps the context handler. | 1 |
ContextAwarePluginManagerTrait:: |
abstract public | function | See \Drupal\Component\Plugin\Discovery\DiscoveryInterface::getDefinitions(). | 1 |
ContextAwarePluginManagerTrait:: |
public | function | See \Drupal\Core\Plugin\Context\ContextAwarePluginManagerInterface::getDefinitionsForContexts(). |