You are here

protected function ContextDefinition::getConstraintObjects 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::getConstraintObjects()
  2. 9 core/lib/Drupal/Core/Plugin/Context/ContextDefinition.php \Drupal\Core\Plugin\Context\ContextDefinition::getConstraintObjects()

Extracts an array of constraints for a context definition object.

Return value

\Symfony\Component\Validator\Constraint[] A list of applied constraints for the context definition.

2 calls to ContextDefinition::getConstraintObjects()
ContextDefinition::isSatisfiedBy in core/lib/Drupal/Core/Plugin/Context/ContextDefinition.php
Determines if this definition is satisfied by a context object.
EntityContextDefinition::getConstraintObjects in core/lib/Drupal/Core/Plugin/Context/EntityContextDefinition.php
Extracts an array of constraints for a context definition object.
1 method overrides ContextDefinition::getConstraintObjects()
EntityContextDefinition::getConstraintObjects in core/lib/Drupal/Core/Plugin/Context/EntityContextDefinition.php
Extracts an array of constraints for a context definition object.

File

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

Class

ContextDefinition
Defines a class for context definitions.

Namespace

Drupal\Core\Plugin\Context

Code

protected function getConstraintObjects() {
  $constraint_definitions = $this
    ->getConstraints();
  $validation_constraint_manager = $this
    ->getTypedDataManager()
    ->getValidationConstraintManager();
  $constraints = [];
  foreach ($constraint_definitions as $constraint_name => $constraint_definition) {
    $constraints[$constraint_name] = $validation_constraint_manager
      ->create($constraint_name, $constraint_definition);
  }
  return $constraints;
}