Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / lib / Drupal / Core / Plugin / Context / ContextAwarePluginManagerTrait.php
1 <?php
2
3 namespace Drupal\Core\Plugin\Context;
4
5 /**
6  * Provides a trait for plugin managers that support context-aware plugins.
7  */
8 trait ContextAwarePluginManagerTrait {
9
10   /**
11    * Wraps the context handler.
12    *
13    * @return \Drupal\Core\Plugin\Context\ContextHandlerInterface
14    */
15   protected function contextHandler() {
16     return \Drupal::service('context.handler');
17   }
18
19   /**
20    * See \Drupal\Core\Plugin\Context\ContextAwarePluginManagerInterface::getDefinitionsForContexts().
21    */
22   public function getDefinitionsForContexts(array $contexts = []) {
23     return $this->contextHandler()->filterPluginDefinitionsByContexts($contexts, $this->getDefinitions());
24   }
25
26   /**
27    * See \Drupal\Component\Plugin\Discovery\DiscoveryInterface::getDefinitions().
28    */
29   abstract public function getDefinitions();
30
31 }