This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/Validator/ConstraintValidatorFactory.php
2010-08-20 23:09:55 +02:00

22 lines
572 B
PHP

<?php
namespace Symfony\Component\Validator;
use Symfony\Component\Validator\ConstraintValidatorFactoryInterface;
use Symfony\Component\Validator\Constraint;
class ConstraintValidatorFactory implements ConstraintValidatorFactoryInterface
{
protected $validators = array();
public function getInstance(Constraint $constraint)
{
$className = $constraint->validatedBy();
if (!isset($this->validators[$className])) {
$this->validators[$className] = new $className();
}
return $this->validators[$className];
}
}