Class

Symfony\Component\Validator\Mapping\ElementMetadata

abstract class ElementMetadata extends GenericMetadata

Contains the metadata of a structural element.

Properties

Constraint[] $constraints
array $constraintsByGroup
integer $cascadingStrategy The strategy for cascading objects.
integer $traversalStrategy The strategy for traversing traversable objects.

Methods

string[] __sleep()

Returns the names of the properties that should be serialized.

from GenericMetadata
__clone()

Clones this object.

from GenericMetadata
GenericMetadata addConstraint(Constraint $constraint)

Adds a constraint.

from GenericMetadata
GenericMetadata addConstraints(array $constraints)

Adds an list of constraints.

from GenericMetadata
Constraint[] getConstraints()

Returns all constraints of this element.

from GenericMetadata
Boolean hasConstraints()

Returns whether this element has any constraints.

from GenericMetadata
Constraint[] findConstraints(string $group)

Returns the constraints of the given group and global ones (* group).

from GenericMetadata
integer getCascadingStrategy()

Returns the strategy for cascading objects.

from GenericMetadata
integer getTraversalStrategy()

Returns the strategy for traversing traversable objects.

from GenericMetadata
accept(ValidationVisitorInterface $visitor, mixed $value, string|string[] $group, string $propertyPath)

Exists for compatibility with the deprecated {@link Symfony\Component\Validator\MetadataInterface}.

from GenericMetadata

Details

in GenericMetadata at line 84
public string[] __sleep()

Returns the names of the properties that should be serialized.

Return Value

string[]

in GenericMetadata at line 97
public __clone()

Clones this object.

in GenericMetadata at line 130
public GenericMetadata 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:

Parameters

Constraint $constraint The constraint to add

Return Value

GenericMetadata This object

Exceptions

ConstraintDefinitionException When trying to add the {@link Traverse} constraint

in GenericMetadata at line 173
public GenericMetadata addConstraints(array $constraints)

Adds an list of constraints.

Parameters

array $constraints The constraints to add

Return Value

GenericMetadata This object

in GenericMetadata at line 187
public Constraint[] getConstraints()

Returns all constraints of this element.

Return Value

Constraint[] A list of Constraint instances

in GenericMetadata at line 197
public Boolean hasConstraints()

Returns whether this element has any constraints.

Return Value

Boolean

in GenericMetadata at line 210
public Constraint[] findConstraints(string $group)

Returns the constraints of the given group and global ones (* group).

Parameters

string $group The group name

Return Value

Constraint[] An list of all the Constraint instances belonging to the group

in GenericMetadata at line 220
public integer getCascadingStrategy()

Returns the strategy for cascading objects.

Return Value

integer The cascading strategy

in GenericMetadata at line 228
public integer getTraversalStrategy()

Returns the strategy for traversing traversable objects.

Return Value

integer The traversal strategy

in GenericMetadata at line 244
public accept(ValidationVisitorInterface $visitor, mixed $value, string|string[] $group, string $propertyPath)

Exists for compatibility with the deprecated {@link Symfony\Component\Validator\MetadataInterface}.

Should not be used.

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