ClassMetadata
class ClassMetadata extends GenericMetadata implements ClassMetadataInterface
Default implementation of {@link ClassMetadataInterface}.
This class supports serialization and cloning.
Properties
Constraint[] | $constraints | from GenericMetadata | |
array | $constraintsByGroup | from GenericMetadata | |
int | $cascadingStrategy | The strategy for cascading objects. | from GenericMetadata |
int | $traversalStrategy | The strategy for traversing traversable objects. | |
string | $name | ||
string | $defaultGroup | ||
MemberMetadata[] | $members | ||
PropertyMetadata[] | $properties | ||
GetterMetadata[] | $getters | ||
array | $groupSequence | ||
bool | $groupSequenceProvider |
Methods
Returns the names of the properties that should be serialized.
Adds an list of constraints.
Returns all constraints for a given validation group.
Class nodes are never cascaded.
Returns the strategy for traversing traversable objects.
Constructs a metadata for the given class.
Returns the name of the backing PHP class.
Returns the name of the default group for this class.
Adds a constraint to the given property.
No description
Adds a constraint to the getter of the given property.
No description
Merges the constraints of the given metadata into this object.
Check if there's any metadata attached to the given named property.
Returns all metadata instances for the given named property.
Returns the names of all constrained properties.
Sets the default group sequence for this class.
Returns whether the "Default" group is overridden by a group sequence.
Returns the group sequence that overrides the "Default" group for this class.
Returns a ReflectionClass instance for this class.
Sets whether a group sequence provider should be used.
Returns whether the "Default" group is overridden by a dynamic group sequence obtained by the validated objects.
Details
at line line 131
string[]
__sleep()
Returns the names of the properties that should be serialized.
in GenericMetadata at line line 96
__clone()
Clones this object.
at line line 180
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 $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
in GenericMetadata at line line 164
GenericMetadata
addConstraints(array $constraints)
Adds an list of constraints.
in GenericMetadata at line line 176
Constraint[]
getConstraints()
Returns all constraints of this element.
in GenericMetadata at line line 186
bool
hasConstraints()
Returns whether this element has any constraints.
in GenericMetadata at line line 196
Constraint[]
findConstraints(string $group)
Returns all constraints for a given validation group.
at line line 452
int
getCascadingStrategy()
Class nodes are never cascaded.
{@inheritdoc}
in GenericMetadata at line line 214
int
getTraversalStrategy()
Returns the strategy for traversing traversable objects.
at line line 117
__construct(string $class)
Constructs a metadata for the given class.
at line line 152
string
getClassName()
Returns the name of the backing PHP class.
at line line 172
string
getDefaultGroup()
Returns the name of the default group for this class.
For each class, the group "Default" is an alias for the group
"
If a class defines a group sequence, validating the class in "Default"
will validate the group sequence. The constraints assigned to "Default"
can still be validated by validating the class in "
at line line 224
ClassMetadata
addPropertyConstraint(string $property, Constraint $constraint)
Adds a constraint to the given property.
at line line 245
ClassMetadata
addPropertyConstraints(string $property, array $constraints)
at line line 265
ClassMetadata
addGetterConstraint(string $property, Constraint $constraint)
Adds a constraint to the getter of the given property.
The name of the getter is assumed to be the name of the property with an uppercased first letter and either the prefix "get" or "is".
at line line 286
ClassMetadata
addGetterConstraints(string $property, array $constraints)
at line line 300
mergeConstraints(ClassMetadata $source)
Merges the constraints of the given metadata into this object.
at line line 332
bool
hasPropertyMetadata(string $property)
Check if there's any metadata attached to the given named property.
at line line 340
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).
at line line 352
string[]
getConstrainedProperties()
Returns the names of all constrained properties.
at line line 366
ClassMetadata
setGroupSequence(array $groupSequence)
Sets the default group sequence for this class.
at line line 392
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()}.
at line line 400
GroupSequence|null
getGroupSequence()
Returns the group sequence that overrides the "Default" group for this class.
at line line 410
ReflectionClass
getReflectionClass()
Returns a ReflectionClass instance for this class.
at line line 426
setGroupSequenceProvider(bool $active)
Sets whether a group sequence provider should be used.
at line line 442
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.