Mercurial > hg > cmmr2012-drupal-site
comparison vendor/symfony/validator/Validator/RecursiveContextualValidator.php @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | a9cd425dd02b |
children |
comparison
equal
deleted
inserted
replaced
4:a9cd425dd02b | 5:12f9dff5fda9 |
---|---|
350 | 350 |
351 /** | 351 /** |
352 * Validates each object in a collection against the constraints defined | 352 * Validates each object in a collection against the constraints defined |
353 * for their classes. | 353 * for their classes. |
354 * | 354 * |
355 * If the parameter $recursive is set to true, nested {@link \Traversable} | 355 * Nested arrays are also iterated. |
356 * objects are iterated as well. Nested arrays are always iterated, | |
357 * regardless of the value of $recursive. | |
358 * | 356 * |
359 * @param iterable $collection The collection | 357 * @param iterable $collection The collection |
360 * @param string $propertyPath The current property path | 358 * @param string $propertyPath The current property path |
361 * @param (string|GroupSequence)[] $groups The validated groups | 359 * @param (string|GroupSequence)[] $groups The validated groups |
362 * @param ExecutionContextInterface $context The current execution context | 360 * @param ExecutionContextInterface $context The current execution context |
363 * | |
364 * @see ClassNode | |
365 * @see CollectionNode | |
366 */ | 361 */ |
367 private function validateEachObjectIn($collection, $propertyPath, array $groups, ExecutionContextInterface $context) | 362 private function validateEachObjectIn($collection, $propertyPath, array $groups, ExecutionContextInterface $context) |
368 { | 363 { |
369 foreach ($collection as $key => $value) { | 364 foreach ($collection as $key => $value) { |
370 if (\is_array($value)) { | 365 if (\is_array($value)) { |
371 // Arrays are always cascaded, independent of the specified | 366 // Also traverse nested arrays |
372 // traversal strategy | |
373 $this->validateEachObjectIn( | 367 $this->validateEachObjectIn( |
374 $value, | 368 $value, |
375 $propertyPath.'['.$key.']', | 369 $propertyPath.'['.$key.']', |
376 $groups, | 370 $groups, |
377 $context | 371 $context |
597 * | 591 * |
598 * In both cases, the value is validated against all constraints defined | 592 * In both cases, the value is validated against all constraints defined |
599 * in the passed metadata object. Then, if the value is an instance of | 593 * in the passed metadata object. Then, if the value is an instance of |
600 * {@link \Traversable} and the selected traversal strategy permits it, | 594 * {@link \Traversable} and the selected traversal strategy permits it, |
601 * the value is traversed and each nested object validated against its own | 595 * the value is traversed and each nested object validated against its own |
602 * constraints. Arrays are always traversed. | 596 * constraints. If the value is an array, it is traversed regardless of |
597 * the given strategy. | |
603 * | 598 * |
604 * @param mixed $value The validated value | 599 * @param mixed $value The validated value |
605 * @param object|null $object The current object | 600 * @param object|null $object The current object |
606 * @param string $cacheKey The key for caching | 601 * @param string $cacheKey The key for caching |
607 * the validated value | 602 * the validated value |
656 return; | 651 return; |
657 } | 652 } |
658 | 653 |
659 $cascadingStrategy = $metadata->getCascadingStrategy(); | 654 $cascadingStrategy = $metadata->getCascadingStrategy(); |
660 | 655 |
661 // Quit unless we have an array or a cascaded object | 656 // Quit unless we cascade |
662 if (!\is_array($value) && !($cascadingStrategy & CascadingStrategy::CASCADE)) { | 657 if (!($cascadingStrategy & CascadingStrategy::CASCADE)) { |
663 return; | 658 return; |
664 } | 659 } |
665 | 660 |
666 // If no specific traversal strategy was requested when this method | 661 // If no specific traversal strategy was requested when this method |
667 // was called, use the traversal strategy of the node's metadata | 662 // was called, use the traversal strategy of the node's metadata |