Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ContextAwarePluginManagerTrait.php

trait 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\Context
View 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

Title Sort descending Modifiers Object type Summary
ContextAwarePluginManagerTrait::contextHandler protected function Wraps the context handler.
ContextAwarePluginManagerTrait::getDefinitions abstract public function See \Drupal\Component\Plugin\Discovery\DiscoveryInterface::getDefinitions().
ContextAwarePluginManagerTrait::getDefinitionsForContexts public function See \Drupal\Core\Plugin\Context\ContextAwarePluginManagerInterface::getDefinitionsForContexts().

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal