You are here

trait ContextAwarePluginManagerTrait in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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

2 files declare their use of ContextAwarePluginManagerTrait
BlockManager.php in core/lib/Drupal/Core/Block/BlockManager.php
Contains \Drupal\Core\Block\BlockManager.
ConditionManager.php in core/lib/Drupal/Core/Condition/ConditionManager.php
Contains \Drupal\Core\Condition\ConditionManager.

File

core/lib/Drupal/Core/Plugin/Context/ContextAwarePluginManagerTrait.php, line 13
Contains \Drupal\Core\Plugin\Context\ContextAwarePluginManagerTrait.

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 = array()) {
    return $this
      ->contextHandler()
      ->filterPluginDefinitionsByContexts($contexts, $this
      ->getDefinitions());
  }

  /**
   * See \Drupal\Component\Plugin\Discovery\DiscoveryInterface::getDefinitions().
   */
  public abstract function getDefinitions();

}

Members