You are here

protected function ContextDefinition::getConstraintObjects in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Plugin/Context/ContextDefinition.php \Drupal\Core\Plugin\Context\ContextDefinition::getConstraintObjects()
  2. 10 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 407

Class

ContextDefinition
Defines a class for context definitions.

Namespace

Drupal\Core\Plugin\Context

Code

protected function getConstraintObjects() {

  // If the backwards compatibility layer is present, delegate to that.
  $this
    ->initializeEntityContextDefinition();
  if ($this->entityContextDefinition) {
    return $this->entityContextDefinition
      ->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;
}