GenericMetadata
class GenericMetadata implements MetadataInterface
A generic container of {@link Constraint} objects.
This class supports serialization and cloning.
Properties
| Constraint[] | $constraints | ||
| array | $constraintsByGroup | ||
| int | $cascadingStrategy | The strategy for cascading objects. | |
| int | $traversalStrategy | The strategy for traversing traversable objects. |
Methods
| string[] | __sleep() Returns the names of the properties that should be serialized. | |
| __clone() Clones this object. | ||
| $this | addConstraint(Constraint $constraint) Adds a constraint. | |
| $this | addConstraints(array $constraints) Adds an list of constraints. | |
| Constraint[] | getConstraints() Returns all constraints of this element. | |
| bool | hasConstraints() Returns whether this element has any constraints. | |
| Constraint[] | findConstraints(string $group) Returns all constraints for a given validation group. | |
| int | getCascadingStrategy() Returns the strategy for cascading objects. | |
| int | getTraversalStrategy() Returns the strategy for traversing traversable objects. | |
| accept(ValidationVisitorInterface $visitor, mixed $value, string|string[] $group, string $propertyPath) deprecated Exists for compatibility with the deprecated {@link Symfony\Component\Validator\MetadataInterface}. |
Details
string[] __sleep()
Returns the names of the properties that should be serialized.
Return Value
| string[] |
__clone()
Clones this object.
$this addConstraint(Constraint $constraint)
Adds a constraint.
If the constraint {@link Valid} is added, the cascading strategy will be changed to {@link CascadingStrategy::CASCADE}. Depending on the properties $traverse and $deep of that constraint, the traversal strategy will be set to one of the following:
- {@link TraversalStrategy::IMPLICIT} if $traverse is enabled and $deep is enabled
- {@link TraversalStrategy::IMPLICIT} | {@link TraversalStrategy::STOP_RECURSION} if $traverse is enabled, but $deep is disabled
- {@link TraversalStrategy::NONE} if $traverse is disabled
Parameters
| Constraint | $constraint |
Return Value
| $this |
Exceptions
| ConstraintDefinitionException | When trying to add the {@link Traverse} constraint |
$this addConstraints(array $constraints)
Adds an list of constraints.
Parameters
| array | $constraints | The constraints to add |
Return Value
| $this |
Constraint[] getConstraints()
Returns all constraints of this element.
Return Value
| Constraint[] | A list of Constraint instances |
bool hasConstraints()
Returns whether this element has any constraints.
Return Value
| bool |
Constraint[] findConstraints(string $group)
Returns all constraints for a given validation group.
Parameters
| string | $group | The validation group |
Return Value
| Constraint[] | A list of constraint instances |
int getCascadingStrategy()
Returns the strategy for cascading objects.
Return Value
| int | The cascading strategy |
int getTraversalStrategy()
Returns the strategy for traversing traversable objects.
Return Value
| int | The traversal strategy |
accept(ValidationVisitorInterface $visitor, mixed $value, string|string[] $group, string $propertyPath) deprecated
deprecated
Exists for compatibility with the deprecated {@link Symfony\Component\Validator\MetadataInterface}.
Should not be used.
Implemented for backward compatibility with Symfony < 2.5.
Parameters
| ValidationVisitorInterface | $visitor | The visitor implementing the validation logic |
| mixed | $value | The value to validate |
| string|string[] | $group | The validation group to validate in |
| string | $propertyPath | The current property path in the validation graph |
Exceptions
| BadMethodCallException |
© 2004–2017 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/2.8/Symfony/Component/Validator/Mapping/GenericMetadata.html