RecursiveValidator.php in Plug 7
File
lib/Symfony/validator/Symfony/Component/Validator/Validator/RecursiveValidator.php
View source
<?php
namespace Symfony\Component\Validator\Validator;
use Symfony\Component\Validator\ConstraintValidatorFactoryInterface;
use Symfony\Component\Validator\Context\ExecutionContextFactoryInterface;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use Symfony\Component\Validator\MetadataFactoryInterface;
use Symfony\Component\Validator\ObjectInitializerInterface;
class RecursiveValidator implements ValidatorInterface {
protected $contextFactory;
protected $metadataFactory;
protected $validatorFactory;
protected $objectInitializers;
public function __construct(ExecutionContextFactoryInterface $contextFactory, MetadataFactoryInterface $metadataFactory, ConstraintValidatorFactoryInterface $validatorFactory, array $objectInitializers = array()) {
$this->contextFactory = $contextFactory;
$this->metadataFactory = $metadataFactory;
$this->validatorFactory = $validatorFactory;
$this->objectInitializers = $objectInitializers;
}
public function startContext($root = null) {
return new RecursiveContextualValidator($this->contextFactory
->createContext($this, $root), $this->metadataFactory, $this->validatorFactory, $this->objectInitializers);
}
public function inContext(ExecutionContextInterface $context) {
return new RecursiveContextualValidator($context, $this->metadataFactory, $this->validatorFactory, $this->objectInitializers);
}
public function getMetadataFor($object) {
return $this->metadataFactory
->getMetadataFor($object);
}
public function hasMetadataFor($object) {
return $this->metadataFactory
->hasMetadataFor($object);
}
public function validate($value, $constraints = null, $groups = null) {
return $this
->startContext($value)
->validate($value, $constraints, $groups)
->getViolations();
}
public function validateProperty($object, $propertyName, $groups = null) {
return $this
->startContext($object)
->validateProperty($object, $propertyName, $groups)
->getViolations();
}
public function validatePropertyValue($objectOrClass, $propertyName, $value, $groups = null) {
return $this
->startContext(is_object($objectOrClass) ? $objectOrClass : $value)
->validatePropertyValue($objectOrClass, $propertyName, $value, $groups)
->getViolations();
}
}