3 namespace Drupal\Component\Plugin\Context;
6 * Interface used to define definition objects found in ContextInterface.
8 * @see \Drupal\Component\Plugin\Context\ContextInterface
10 * @todo WARNING: This interface is going to receive some additions as part of
11 * https://www.drupal.org/node/2346999.
13 interface ContextDefinitionInterface {
16 * Gets a human readable label.
21 public function getLabel();
24 * Sets the human readable label.
26 * @param string $label
31 public function setLabel($label);
34 * Gets a human readable description.
37 * The description, or NULL if no description is available.
39 public function getDescription();
42 * Sets the human readable description.
44 * @param string|null $description
45 * The description to set.
49 public function setDescription($description);
52 * Gets the data type needed by the context.
54 * If the context is multiple-valued, this represents the type of each value.
59 public function getDataType();
62 * Sets the data type needed by the context.
64 * @param string $data_type
65 * The data type to set.
69 public function setDataType($data_type);
72 * Determines whether the data is multi-valued, i.e. a list of data items.
75 * Whether the data is multi-valued; i.e. a list of data items.
77 public function isMultiple();
80 * Sets whether the data is multi-valued.
82 * @param bool $multiple
83 * (optional) Whether the data is multi-valued. Defaults to TRUE.
87 public function setMultiple($multiple = TRUE);
90 * Determines whether the context is required.
92 * For required data a non-NULL value is mandatory.
95 * Whether a data value is required.
97 public function isRequired();
100 * Sets whether the data is required.
102 * @param bool $required
103 * (optional) Whether the data is multi-valued. Defaults to TRUE.
107 public function setRequired($required = TRUE);
110 * Gets the default value for this context definition.
113 * The default value or NULL if no default value is set.
115 public function getDefaultValue();
118 * Sets the default data value.
120 * @param mixed $default_value
121 * The default value to be set or NULL to remove any default value.
125 public function setDefaultValue($default_value);
128 * Gets an array of validation constraints.
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.
135 public function getConstraints();
138 * Sets the array of validation constraints.
140 * NOTE: This will override any previously set constraints. In most cases
141 * ContextDefinitionInterface::addConstraint() should be used instead.
143 * @param array $constraints
144 * The array of constraints.
148 * @see self::addConstraint()
150 public function setConstraints(array $constraints);
153 * Adds a validation constraint.
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.
162 public function addConstraint($constraint_name, $options = NULL);
165 * Gets a validation constraint.
167 * @param string $constraint_name
168 * The name of the constraint, i.e. its plugin id.
171 * A validation constraint definition which can be used for instantiating a
172 * \Symfony\Component\Validator\Constraint object.
174 public function getConstraint($constraint_name);