class LegacyValidator in Plug 7
A validator that supports both the API of Symfony < 2.5 and Symfony 2.5+.
This class is incompatible with PHP versions < 5.3.9, because it implements two different interfaces specifying the same method validate():
- {@link \Symfony\Component\Validator\ValidatorInterface}
- {@link \Symfony\Component\Validator\Validator\ValidatorInterface}
In PHP versions prior to 5.3.9, either use {@link RecursiveValidator} or the deprecated class {@link \Symfony\Component\Validator\Validator} instead.
@since 2.5 @author Bernhard Schussek <bschussek@gmail.com>
Hierarchy
- class \Symfony\Component\Validator\Validator\RecursiveValidator implements ValidatorInterface
- class \Symfony\Component\Validator\Validator\LegacyValidator implements ValidatorInterface
Expanded class hierarchy of LegacyValidator
Deprecated
Implemented for backwards compatibility with Symfony < 2.5. To be removed in Symfony 3.0.
See also
\Symfony\Component\Validator\ValidatorInterface
\Symfony\Component\Validator\Validator\ValidatorInterface
3 files declare their use of LegacyValidator
- LegacyValidator2Dot5ApiTest.php in lib/
Symfony/ validator/ Symfony/ Component/ Validator/ Tests/ Validator/ LegacyValidator2Dot5ApiTest.php - LegacyValidatorLegacyApiTest.php in lib/
Symfony/ validator/ Symfony/ Component/ Validator/ Tests/ Validator/ LegacyValidatorLegacyApiTest.php - ValidatorBuilder.php in lib/
Symfony/ validator/ Symfony/ Component/ Validator/ ValidatorBuilder.php
File
- lib/
Symfony/ validator/ Symfony/ Component/ Validator/ Validator/ LegacyValidator.php, line 40
Namespace
Symfony\Component\Validator\ValidatorView source
class LegacyValidator extends RecursiveValidator implements LegacyValidatorInterface {
public function validate($value, $groups = null, $traverse = false, $deep = false) {
$numArgs = func_num_args();
// Use new signature if constraints are given in the second argument
if (self::testConstraints($groups) && ($numArgs < 3 || 3 === $numArgs && self::testGroups($traverse))) {
// Rename to avoid total confusion ;)
$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);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
LegacyValidator:: |
public | function |
Returns the factory for metadata instances. Overrides ValidatorInterface:: |
|
LegacyValidator:: |
private static | function | ||
LegacyValidator:: |
private static | function | ||
LegacyValidator:: |
public | function |
Validates a value against a constraint or a list of constraints. Overrides RecursiveValidator:: |
|
LegacyValidator:: |
public | function |
Validates a value against a constraint or a list of constraints. Overrides ValidatorInterface:: |
|
RecursiveValidator:: |
protected | property | ||
RecursiveValidator:: |
protected | property | ||
RecursiveValidator:: |
protected | property | ||
RecursiveValidator:: |
protected | property | ||
RecursiveValidator:: |
public | function |
Returns the metadata for the given value. Overrides MetadataFactoryInterface:: |
|
RecursiveValidator:: |
public | function |
Returns whether the class is able to return metadata for the given value. Overrides MetadataFactoryInterface:: |
|
RecursiveValidator:: |
public | function |
Returns a validator in the given execution context. Overrides ValidatorInterface:: |
|
RecursiveValidator:: |
public | function |
Starts a new validation context and returns a validator for that context. Overrides ValidatorInterface:: |
|
RecursiveValidator:: |
public | function |
Validates a property of an object against the constraints specified
for this property. Overrides ValidatorInterface:: |
|
RecursiveValidator:: |
public | function |
Validates a value against the constraints specified for an object's
property. Overrides ValidatorInterface:: |
|
RecursiveValidator:: |
public | function | Creates a new validator. |