Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / lib / Drupal / Component / Plugin / Context / ContextDefinitionInterface.php
1 <?php
2
3 namespace Drupal\Component\Plugin\Context;
4
5 /**
6  * Interface used to define definition objects found in ContextInterface.
7  *
8  * @see \Drupal\Component\Plugin\Context\ContextInterface
9  *
10  * @todo WARNING: This interface is going to receive some additions as part of
11  * https://www.drupal.org/node/2346999.
12  */
13 interface ContextDefinitionInterface {
14
15   /**
16    * Gets a human readable label.
17    *
18    * @return string
19    *   The label.
20    */
21   public function getLabel();
22
23   /**
24    * Sets the human readable label.
25    *
26    * @param string $label
27    *   The label to set.
28    *
29    * @return $this
30    */
31   public function setLabel($label);
32
33   /**
34    * Gets a human readable description.
35    *
36    * @return string|null
37    *   The description, or NULL if no description is available.
38    */
39   public function getDescription();
40
41   /**
42    * Sets the human readable description.
43    *
44    * @param string|null $description
45    *   The description to set.
46    *
47    * @return $this
48    */
49   public function setDescription($description);
50
51   /**
52    * Gets the data type needed by the context.
53    *
54    * If the context is multiple-valued, this represents the type of each value.
55    *
56    * @return string
57    *   The data type.
58    */
59   public function getDataType();
60
61   /**
62    * Sets the data type needed by the context.
63    *
64    * @param string $data_type
65    *   The data type to set.
66    *
67    * @return $this
68    */
69   public function setDataType($data_type);
70
71   /**
72    * Determines whether the data is multi-valued, i.e. a list of data items.
73    *
74    * @return bool
75    *   Whether the data is multi-valued; i.e. a list of data items.
76    */
77   public function isMultiple();
78
79   /**
80    * Sets whether the data is multi-valued.
81    *
82    * @param bool $multiple
83    *   (optional) Whether the data is multi-valued. Defaults to TRUE.
84    *
85    * @return $this
86    */
87   public function setMultiple($multiple = TRUE);
88
89   /**
90    * Determines whether the context is required.
91    *
92    * For required data a non-NULL value is mandatory.
93    *
94    * @return bool
95    *   Whether a data value is required.
96    */
97   public function isRequired();
98
99   /**
100    * Sets whether the data is required.
101    *
102    * @param bool $required
103    *   (optional) Whether the data is multi-valued. Defaults to TRUE.
104    *
105    * @return $this
106    */
107   public function setRequired($required = TRUE);
108
109   /**
110    * Gets the default value for this context definition.
111    *
112    * @return mixed
113    *   The default value or NULL if no default value is set.
114    */
115   public function getDefaultValue();
116
117   /**
118    * Sets the default data value.
119    *
120    * @param mixed $default_value
121    *   The default value to be set or NULL to remove any default value.
122    *
123    * @return $this
124    */
125   public function setDefaultValue($default_value);
126
127   /**
128    * Gets an array of validation constraints.
129    *
130    * @return array
131    *   An array of validation constraint definitions, keyed by constraint name.
132    *   Each constraint definition can be used for instantiating
133    *   \Symfony\Component\Validator\Constraint objects.
134    */
135   public function getConstraints();
136
137   /**
138    * Sets the array of validation constraints.
139    *
140    * NOTE: This will override any previously set constraints. In most cases
141    * ContextDefinitionInterface::addConstraint() should be used instead.
142    *
143    * @param array $constraints
144    *   The array of constraints.
145    *
146    * @return $this
147    *
148    * @see self::addConstraint()
149    */
150   public function setConstraints(array $constraints);
151
152   /**
153    * Adds a validation constraint.
154    *
155    * @param string $constraint_name
156    *   The name of the constraint to add, i.e. its plugin id.
157    * @param array|null $options
158    *   The constraint options as required by the constraint plugin, or NULL.
159    *
160    * @return $this
161    */
162   public function addConstraint($constraint_name, $options = NULL);
163
164   /**
165    * Gets a validation constraint.
166    *
167    * @param string $constraint_name
168    *   The name of the constraint, i.e. its plugin id.
169    *
170    * @return array
171    *   A validation constraint definition which can be used for instantiating a
172    *   \Symfony\Component\Validator\Constraint object.
173    */
174   public function getConstraint($constraint_name);
175
176 }