function ContextDefinition::__construct
Same name in this branch
- 10 core/lib/Drupal/Core/Annotation/ContextDefinition.php \Drupal\Core\Annotation\ContextDefinition::__construct()
Same name in other branches
- 9 core/lib/Drupal/Core/Annotation/ContextDefinition.php \Drupal\Core\Annotation\ContextDefinition::__construct()
- 9 core/lib/Drupal/Core/Plugin/Context/ContextDefinition.php \Drupal\Core\Plugin\Context\ContextDefinition::__construct()
- 8.9.x core/lib/Drupal/Core/Annotation/ContextDefinition.php \Drupal\Core\Annotation\ContextDefinition::__construct()
- 8.9.x core/lib/Drupal/Core/Plugin/Context/ContextDefinition.php \Drupal\Core\Plugin\Context\ContextDefinition::__construct()
- 11.x core/lib/Drupal/Core/Annotation/ContextDefinition.php \Drupal\Core\Annotation\ContextDefinition::__construct()
- 11.x core/lib/Drupal/Core/Plugin/Context/ContextDefinition.php \Drupal\Core\Plugin\Context\ContextDefinition::__construct()
Constructs a new context definition object.
Parameters
string $data_type: The required data type.
string|null|\Stringable $label: The label of this context definition for the UI.
bool $required: Whether the context definition is required.
bool $multiple: Whether the context definition is multivalue.
string|null $description: The description of this context definition for the UI.
mixed $default_value: The default value of this definition.
array $constraints: An array of constraints keyed by the constraint name and a value of an array constraint options or a NULL.
1 method overrides ContextDefinition::__construct()
- EntityContextDefinition::__construct in core/
lib/ Drupal/ Core/ Plugin/ Context/ EntityContextDefinition.php - Constructs a new context definition object.
File
-
core/
lib/ Drupal/ Core/ Plugin/ Context/ ContextDefinition.php, line 108
Class
- ContextDefinition
- Defines a class for context definitions.
Namespace
Drupal\Core\Plugin\ContextCode
public function __construct($data_type = 'any', $label = NULL, $required = TRUE, $multiple = FALSE, $description = NULL, $default_value = NULL, array $constraints = []) {
$this->dataType = $data_type;
$this->label = $label;
$this->isRequired = $required;
$this->isMultiple = $multiple;
$this->description = $description;
$this->defaultValue = $default_value;
foreach ($constraints as $constraint_name => $options) {
$this->addConstraint($constraint_name, $options);
}
assert(!str_starts_with($data_type, 'entity:') || $this instanceof EntityContextDefinition);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.