d1ff95340c0375f544fa06319ffc8f62192c3cc7
[yaffs-website] / web / core / lib / Drupal / Component / Plugin / Definition / ContextAwarePluginDefinitionInterface.php
1 <?php
2
3 namespace Drupal\Component\Plugin\Definition;
4
5 use Drupal\Component\Plugin\Context\ContextDefinitionInterface;
6
7 /**
8  * Provides an interface for plugin definitions which use contexts.
9  *
10  * @ingroup Plugin
11  */
12 interface ContextAwarePluginDefinitionInterface extends PluginDefinitionInterface {
13
14   /**
15    * Checks if the plugin defines a particular context.
16    *
17    * @param string $name
18    *   The context name.
19    *
20    * @return bool
21    *   TRUE if the plugin defines the given context, otherwise FALSE.
22    */
23   public function hasContextDefinition($name);
24
25   /**
26    * Returns all context definitions for this plugin.
27    *
28    * @return \Drupal\Component\Plugin\Context\ContextDefinitionInterface[]
29    *   The context definitions.
30    */
31   public function getContextDefinitions();
32
33   /**
34    * Returns a particular context definition for this plugin.
35    *
36    * @param string $name
37    *   The context name.
38    *
39    * @return \Drupal\Component\Plugin\Context\ContextDefinitionInterface
40    *   The context definition.
41    *
42    * @throws \Drupal\Component\Plugin\Exception\ContextException
43    *   Thrown if the plugin does not define the given context.
44    */
45   public function getContextDefinition($name);
46
47   /**
48    * Adds a context to this plugin definition.
49    *
50    * @param string $name
51    *   The context name.
52    * @param \Drupal\Component\Plugin\Context\ContextDefinitionInterface $definition
53    *   The context definition.
54    *
55    * @return $this
56    *   The called object.
57    */
58   public function addContextDefinition($name, ContextDefinitionInterface $definition);
59
60   /**
61    * Removes a context definition from this plugin.
62    *
63    * @param string $name
64    *   The context name.
65    *
66    * @return $this
67    *   The called object.
68    */
69   public function removeContextDefinition($name);
70
71 }