private function RecursiveContextualValidator::validateObject in Plug 7
Validates an object against the constraints defined for its class.
If no metadata is available for the class, but the class is an instance of {@link \Traversable} and the selected traversal strategy allows traversal, the object will be iterated and each nested object will be validated instead.
Parameters
object $object The object to cascade:
string $propertyPath The current property path:
string[] $groups The validated groups:
int $traversalStrategy The strategy for traversing the: cascaded object
ExecutionContextInterface $context The current execution context:
Throws
NoSuchMetadataException If the object has no associated metadata and does not implement {@link \Traversable} or if traversal is disabled via the $traversalStrategy argument
UnsupportedMetadataException If the metadata returned by the metadata factory does not implement {@link ClassMetadataInterface}
3 calls to RecursiveContextualValidator::validateObject()
- RecursiveContextualValidator::validate in lib/
Symfony/ validator/ Symfony/ Component/ Validator/ Validator/ RecursiveContextualValidator.php - Validates a value against a constraint or a list of constraints.
- RecursiveContextualValidator::validateEachObjectIn in lib/
Symfony/ validator/ Symfony/ Component/ Validator/ Validator/ RecursiveContextualValidator.php - Validates each object in a collection against the constraints defined for their classes.
- RecursiveContextualValidator::validateGenericNode in lib/
Symfony/ validator/ Symfony/ Component/ Validator/ Validator/ RecursiveContextualValidator.php - Validates a node that is not a class node.
File
- lib/
Symfony/ validator/ Symfony/ Component/ Validator/ Validator/ RecursiveContextualValidator.php, line 332
Class
- RecursiveContextualValidator
- Recursive implementation of {@link ContextualValidatorInterface}.
Namespace
Symfony\Component\Validator\ValidatorCode
private function validateObject($object, $propertyPath, array $groups, $traversalStrategy, ExecutionContextInterface $context) {
try {
$classMetadata = $this->metadataFactory
->getMetadataFor($object);
if (!$classMetadata instanceof ClassMetadataInterface) {
throw new UnsupportedMetadataException(sprintf('The metadata factory should return instances of ' . '"Symfony\\Component\\Validator\\Mapping\\ClassMetadataInterface", ' . 'got: "%s".', is_object($classMetadata) ? get_class($classMetadata) : gettype($classMetadata)));
}
$this
->validateClassNode($object, spl_object_hash($object), $classMetadata, $propertyPath, $groups, null, $traversalStrategy, $context);
} catch (NoSuchMetadataException $e) {
// Rethrow if not Traversable
if (!$object instanceof \Traversable) {
throw $e;
}
// Rethrow unless IMPLICIT or TRAVERSE
if (!($traversalStrategy & (TraversalStrategy::IMPLICIT | TraversalStrategy::TRAVERSE))) {
throw $e;
}
$this
->validateEachObjectIn($object, $propertyPath, $groups, $traversalStrategy & TraversalStrategy::STOP_RECURSION, $context);
}
}