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.

getConstraints()

Returns all constraints of this element.

bool
hasConstraints()

Returns whether this element has any constraints.

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.

Details

at line line 81
string[] __sleep()

Returns the names of the properties that should be serialized.

Return Value

string[]

at line line 94
__clone()

Clones this object.

at line line 124
$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 $traverse property of that constraint, the traversal strategy will be set to one of the following:

  • {@link TraversalStrategy::IMPLICIT} if $traverse is enabled
  • {@link TraversalStrategy::NONE} if $traverse is disabled

Parameters

Constraint $constraint The constraint to add

Return Value

$this

Exceptions

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

at line line 162
$this addConstraints(array $constraints)

Adds an list of constraints.

Parameters

array $constraints The constraints to add

Return Value

$this

at line line 174
Constraint[] getConstraints()

Returns all constraints of this element.

Return Value

Constraint[] A list of Constraint instances

at line line 184
bool hasConstraints()

Returns whether this element has any constraints.

Return Value

bool

at line line 194
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

at line line 204
int getCascadingStrategy()

Returns the strategy for cascading objects.

Return Value

int The cascading strategy

at line line 212
int getTraversalStrategy()

Returns the strategy for traversing traversable objects.

Return Value

int The traversal strategy