22 lines
572 B
PHP
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];
|
|
}
|
|
} |