interface ClassMetadataInterface implements MetadataInterface, PropertyMetadataContainerInterface, ClassBasedInterface

Stores all metadata needed for validating objects of specific class.

Most importantly, the metadata stores the constraints against which an object and its properties should be validated.

Additionally, the metadata stores whether the "Default" group is overridden by a group sequence for that class and whether instances of that class should be traversed or not.

Methods

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

Implementation of the Visitor design pattern.

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.

getConstraints()

Returns all constraints of this element.

bool
hasPropertyMetadata(string $property)

Check if there's any metadata attached to the given named property.

getPropertyMetadata(string $property)

Returns all metadata instances for the given named property.

string
getClassName()

Returns the name of the backing PHP class.

string[]
getConstrainedProperties()

Returns the names of all constrained properties.

bool
hasGroupSequence()

Returns whether the "Default" group is overridden by a group sequence.

getGroupSequence()

Returns the group sequence that overrides the "Default" group for this class.

bool
isGroupSequenceProvider()

Returns whether the "Default" group is overridden by a dynamic group sequence obtained by the validated objects.

Details

in MetadataInterface at line 63
accept(ValidationVisitorInterface $visitor, mixed $value, string|string[] $group, string $propertyPath) deprecated

deprecated since version 2.5, to be removed in 3.0.

Implementation of the Visitor design pattern.

Calls {@link ValidationVisitorInterface::visit} and then forwards the accept()-call to all property metadata instances.

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

in MetadataInterface at line 72
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

in MetadataInterface at line 41
int getCascadingStrategy()

Returns the strategy for cascading objects.

Return Value

int The cascading strategy

See also

CascadingStrategy

in MetadataInterface at line 50
int getTraversalStrategy()

Returns the strategy for traversing traversable objects.

Return Value

int The traversal strategy

See also

TraversalStrategy

in MetadataInterface at line 57
Constraint[] getConstraints()

Returns all constraints of this element.

Return Value

Constraint[] A list of Constraint instances

bool hasPropertyMetadata(string $property)

Check if there's any metadata attached to the given named property.

Parameters

string $property The property name

Return Value

bool

PropertyMetadataInterface[] getPropertyMetadata(string $property)

Returns all metadata instances for the given named property.

If your implementation does not support properties, simply throw an exception in this method (for example a BadMethodCallException).

Parameters

string $property The property name

Return Value

PropertyMetadataInterface[] A list of metadata instances. Empty if no metadata exists for the property.

in ClassBasedInterface at line 29
string getClassName()

Returns the name of the backing PHP class.

Return Value

string The name of the backing class

at line 41
string[] getConstrainedProperties()

Returns the names of all constrained properties.

Return Value

string[] A list of property names

at line 52
bool hasGroupSequence()

Returns whether the "Default" group is overridden by a group sequence.

If it is, you can access the group sequence with {@link getGroupSequence()}.

Return Value

bool Returns true if the "Default" group is overridden

See also

GroupSequence

at line 62
GroupSequence|null getGroupSequence()

Returns the group sequence that overrides the "Default" group for this class.

Return Value

GroupSequence|null The group sequence or null

See also

GroupSequence

at line 78
bool isGroupSequenceProvider()

Returns whether the "Default" group is overridden by a dynamic group sequence obtained by the validated objects.

If this method returns true, the class must implement {@link \Symfony\Component\Validator\GroupSequenceProviderInterface}. This interface will be used to obtain the group sequence when an object of this class is validated.

Return Value

bool Returns true if the "Default" group is overridden by a dynamic group sequence

See also

GroupSequenceProviderInterface