You are here

public function ContextDefinition::setConstraints in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Plugin/Context/ContextDefinition.php \Drupal\Core\Plugin\Context\ContextDefinition::setConstraints()
  2. 9 core/lib/Drupal/Core/Plugin/Context/ContextDefinition.php \Drupal\Core\Plugin\Context\ContextDefinition::setConstraints()

Sets the array of validation constraints.

NOTE: This will override any previously set constraints. In most cases ContextDefinitionInterface::addConstraint() should be used instead.

Parameters

array $constraints: The array of constraints.

Return value

$this

Overrides ContextDefinitionInterface::setConstraints

See also

self::addConstraint()

File

core/lib/Drupal/Core/Plugin/Context/ContextDefinition.php, line 227

Class

ContextDefinition
Defines a class for context definitions.

Namespace

Drupal\Core\Plugin\Context

Code

public function setConstraints(array $constraints) {
  $this->constraints = $constraints;
  return $this;
}