comparison vendor/symfony/validator/Validator/RecursiveContextualValidator.php @ 14:1fec387a4317

Update Drupal core to 8.5.2 via Composer
author Chris Cannam
date Mon, 23 Apr 2018 09:46:53 +0100
parents 4c8ae668cc8c
children 129ea1e6d783
comparison
equal deleted inserted replaced
13:5fb285c0d0e3 14:1fec387a4317
36 * 36 *
37 * @author Bernhard Schussek <bschussek@gmail.com> 37 * @author Bernhard Schussek <bschussek@gmail.com>
38 */ 38 */
39 class RecursiveContextualValidator implements ContextualValidatorInterface 39 class RecursiveContextualValidator implements ContextualValidatorInterface
40 { 40 {
41 /**
42 * @var ExecutionContextInterface
43 */
44 private $context; 41 private $context;
45
46 /**
47 * @var string
48 */
49 private $defaultPropertyPath; 42 private $defaultPropertyPath;
50
51 /**
52 * @var array
53 */
54 private $defaultGroups; 43 private $defaultGroups;
55
56 /**
57 * @var MetadataFactoryInterface
58 */
59 private $metadataFactory; 44 private $metadataFactory;
60
61 /**
62 * @var ConstraintValidatorFactoryInterface
63 */
64 private $validatorFactory; 45 private $validatorFactory;
65
66 /**
67 * @var ObjectInitializerInterface[]
68 */
69 private $objectInitializers; 46 private $objectInitializers;
70 47
71 /** 48 /**
72 * Creates a validator for the given context. 49 * Creates a validator for the given context.
73 * 50 *
129 $metadata = new GenericMetadata(); 106 $metadata = new GenericMetadata();
130 $metadata->addConstraints($constraints); 107 $metadata->addConstraints($constraints);
131 108
132 $this->validateGenericNode( 109 $this->validateGenericNode(
133 $value, 110 $value,
134 null, 111 $previousObject,
135 is_object($value) ? spl_object_hash($value) : null, 112 is_object($value) ? spl_object_hash($value) : null,
136 $metadata, 113 $metadata,
137 $this->defaultPropertyPath, 114 $this->defaultPropertyPath,
138 $groups, 115 $groups,
139 null, 116 null,
259 $propertyMetadatas = $classMetadata->getPropertyMetadata($propertyName); 236 $propertyMetadatas = $classMetadata->getPropertyMetadata($propertyName);
260 $groups = $groups ? $this->normalizeGroups($groups) : $this->defaultGroups; 237 $groups = $groups ? $this->normalizeGroups($groups) : $this->defaultGroups;
261 238
262 if (is_object($objectOrClass)) { 239 if (is_object($objectOrClass)) {
263 $object = $objectOrClass; 240 $object = $objectOrClass;
241 $class = get_class($object);
264 $cacheKey = spl_object_hash($objectOrClass); 242 $cacheKey = spl_object_hash($objectOrClass);
265 $propertyPath = PropertyPath::append($this->defaultPropertyPath, $propertyName); 243 $propertyPath = PropertyPath::append($this->defaultPropertyPath, $propertyName);
266 } else { 244 } else {
267 // $objectOrClass contains a class name 245 // $objectOrClass contains a class name
268 $object = null; 246 $object = null;
247 $class = $objectOrClass;
269 $cacheKey = null; 248 $cacheKey = null;
270 $propertyPath = $this->defaultPropertyPath; 249 $propertyPath = $this->defaultPropertyPath;
271 } 250 }
272 251
273 $previousValue = $this->context->getValue(); 252 $previousValue = $this->context->getValue();
278 257
279 foreach ($propertyMetadatas as $propertyMetadata) { 258 foreach ($propertyMetadatas as $propertyMetadata) {
280 $this->validateGenericNode( 259 $this->validateGenericNode(
281 $value, 260 $value,
282 $object, 261 $object,
283 $cacheKey.':'.get_class($object).':'.$propertyName, 262 $cacheKey.':'.$class.':'.$propertyName,
284 $propertyMetadata, 263 $propertyMetadata,
285 $propertyPath, 264 $propertyPath,
286 $groups, 265 $groups,
287 null, 266 null,
288 TraversalStrategy::IMPLICIT, 267 TraversalStrategy::IMPLICIT,
393 * 372 *
394 * If the parameter $recursive is set to true, nested {@link \Traversable} 373 * If the parameter $recursive is set to true, nested {@link \Traversable}
395 * objects are iterated as well. Nested arrays are always iterated, 374 * objects are iterated as well. Nested arrays are always iterated,
396 * regardless of the value of $recursive. 375 * regardless of the value of $recursive.
397 * 376 *
398 * @param array|\Traversable $collection The collection 377 * @param iterable $collection The collection
399 * @param string $propertyPath The current property path 378 * @param string $propertyPath The current property path
400 * @param string[] $groups The validated groups 379 * @param string[] $groups The validated groups
401 * @param ExecutionContextInterface $context The current execution context 380 * @param ExecutionContextInterface $context The current execution context
402 * 381 *
403 * @see ClassNode 382 * @see ClassNode