You are here

private function RecursiveContextualValidator::validateEachObjectIn in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/validator/Validator/RecursiveContextualValidator.php \Symfony\Component\Validator\Validator\RecursiveContextualValidator::validateEachObjectIn()

Validates each object in a collection against the constraints defined for their classes.

If the parameter $recursive is set to true, nested {@link \Traversable} objects are iterated as well. Nested arrays are always iterated, regardless of the value of $recursive.

Parameters

array|\Traversable $collection The collection:

string $propertyPath The current property path:

string[] $groups The validated groups:

bool $stopRecursion Whether to disable: recursive iteration. For backwards compatibility with Symfony < 2.5.

ExecutionContextInterface $context The current execution context:

See also

ClassNode

CollectionNode

4 calls to RecursiveContextualValidator::validateEachObjectIn()
RecursiveContextualValidator::validate in vendor/symfony/validator/Validator/RecursiveContextualValidator.php
Validates a value against a constraint or a list of constraints.
RecursiveContextualValidator::validateClassNode in vendor/symfony/validator/Validator/RecursiveContextualValidator.php
Validates a class node.
RecursiveContextualValidator::validateGenericNode in vendor/symfony/validator/Validator/RecursiveContextualValidator.php
Validates a node that is not a class node.
RecursiveContextualValidator::validateObject in vendor/symfony/validator/Validator/RecursiveContextualValidator.php
Validates an object against the constraints defined for its class.

File

vendor/symfony/validator/Validator/RecursiveContextualValidator.php, line 407

Class

RecursiveContextualValidator
Recursive implementation of {@link ContextualValidatorInterface}.

Namespace

Symfony\Component\Validator\Validator

Code

private function validateEachObjectIn($collection, $propertyPath, array $groups, $stopRecursion, ExecutionContextInterface $context) {
  if ($stopRecursion) {
    $traversalStrategy = TraversalStrategy::NONE;
  }
  else {
    $traversalStrategy = TraversalStrategy::IMPLICIT;
  }
  foreach ($collection as $key => $value) {
    if (is_array($value)) {

      // Arrays are always cascaded, independent of the specified
      // traversal strategy
      // (BC with Symfony < 2.5)
      $this
        ->validateEachObjectIn($value, $propertyPath . '[' . $key . ']', $groups, $stopRecursion, $context);
      continue;
    }

    // Scalar and null values in the collection are ignored
    // (BC with Symfony < 2.5)
    if (is_object($value)) {
      $this
        ->validateObject($value, $propertyPath . '[' . $key . ']', $groups, $traversalStrategy, $context);
    }
  }
}