2011-01-19 14:02:00 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of the Symfony package.
|
|
|
|
*
|
2011-03-06 11:40:06 +00:00
|
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
2011-01-19 14:02:00 +00:00
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
2012-04-02 04:52:14 +01:00
|
|
|
namespace Symfony\Component\Validator;
|
|
|
|
|
2011-01-19 14:02:00 +00:00
|
|
|
use Symfony\Component\Validator\Mapping\ClassMetadataFactoryInterface;
|
|
|
|
|
|
|
|
/**
|
2011-03-01 17:55:38 +00:00
|
|
|
* Default implementation of ValidatorContextInterface
|
2011-01-19 14:02:00 +00:00
|
|
|
*
|
2011-03-06 11:40:06 +00:00
|
|
|
* @author Bernhard Schussek <bernhard.schussek@symfony.com>
|
2011-01-19 14:02:00 +00:00
|
|
|
*/
|
|
|
|
class ValidatorContext implements ValidatorContextInterface
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The class metadata factory used in the new validator
|
|
|
|
* @var ClassMetadataFactoryInterface
|
|
|
|
*/
|
|
|
|
protected $classMetadataFactory = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The constraint validator factory used in the new validator
|
|
|
|
* @var ConstraintValidatorFactoryInterface
|
|
|
|
*/
|
|
|
|
protected $constraintValidatorFactory = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
2011-03-30 22:10:30 +01:00
|
|
|
public function setClassMetadataFactory(ClassMetadataFactoryInterface $classMetadataFactory)
|
2011-01-19 14:02:00 +00:00
|
|
|
{
|
|
|
|
$this->classMetadataFactory = $classMetadataFactory;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
2011-03-30 22:10:30 +01:00
|
|
|
public function setConstraintValidatorFactory(ConstraintValidatorFactoryInterface $constraintValidatorFactory)
|
2011-01-19 14:02:00 +00:00
|
|
|
{
|
|
|
|
$this->constraintValidatorFactory = $constraintValidatorFactory;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
public function getValidator()
|
|
|
|
{
|
|
|
|
return new Validator(
|
|
|
|
$this->classMetadataFactory,
|
|
|
|
$this->constraintValidatorFactory
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the class metadata factory used in the new validator
|
|
|
|
*
|
|
|
|
* @return ClassMetadataFactoryInterface The factory instance
|
|
|
|
*/
|
|
|
|
public function getClassMetadataFactory()
|
|
|
|
{
|
|
|
|
return $this->classMetadataFactory;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the constraint validator factory used in the new validator
|
|
|
|
*
|
|
|
|
* @return ConstraintValidatorFactoryInterface The factory instance
|
|
|
|
*/
|
|
|
|
public function getConstraintValidatorFactory()
|
|
|
|
{
|
|
|
|
return $this->constraintValidatorFactory;
|
|
|
|
}
|
|
|
|
}
|