LegacyValidator.php in Plug 7
File
lib/Symfony/validator/Symfony/Component/Validator/Validator/LegacyValidator.php
View source
<?php
namespace Symfony\Component\Validator\Validator;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Constraints\GroupSequence;
use Symfony\Component\Validator\Constraints\Valid;
use Symfony\Component\Validator\ValidatorInterface as LegacyValidatorInterface;
class LegacyValidator extends RecursiveValidator implements LegacyValidatorInterface {
public function validate($value, $groups = null, $traverse = false, $deep = false) {
$numArgs = func_num_args();
if (self::testConstraints($groups) && ($numArgs < 3 || 3 === $numArgs && self::testGroups($traverse))) {
$constraints = $groups;
$groups = $traverse;
return parent::validate($value, $constraints, $groups);
}
$constraint = new Valid(array(
'traverse' => $traverse,
'deep' => $deep,
));
return parent::validate($value, $constraint, $groups);
}
public function validateValue($value, $constraints, $groups = null) {
return parent::validate($value, $constraints, $groups);
}
public function getMetadataFactory() {
return $this->metadataFactory;
}
private static function testConstraints($constraints) {
return null === $constraints || $constraints instanceof Constraint || is_array($constraints) && current($constraints) instanceof Constraint;
}
private static function testGroups($groups) {
return null === $groups || is_string($groups) || $groups instanceof GroupSequence || is_array($groups) && (is_string(current($groups)) || current($groups) instanceof GroupSequence);
}
}
Classes
Name |
Description |
LegacyValidator Deprecated |
A validator that supports both the API of Symfony < 2.5 and Symfony 2.5+. |