class ClassMetadata extends GenericMetadata implements ClassMetadataInterface
Default implementation of {@link ClassMetadataInterface}.
This class supports serialization and cloning.
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 |
string[] | __sleep() Returns the names of the properties that should be serialized. | |
__clone() Clones this object. | from GenericMetadata | |
$this | addConstraint(Constraint $constraint) Adds a constraint. | |
$this | addConstraints(array $constraints) Adds an list of constraints. | from GenericMetadata |
Constraint[] | getConstraints() Returns all constraints of this element. | from GenericMetadata |
bool | hasConstraints() Returns whether this element has any constraints. | from GenericMetadata |
Constraint[] | findConstraints(string $group) Returns all constraints for a given validation group. | from GenericMetadata |
int | getCascadingStrategy() Class nodes are never cascaded. | |
int | getTraversalStrategy() Returns the strategy for traversing traversable objects. | from GenericMetadata |
__construct(string $class) | ||
string | getClassName() Returns the name of the backing PHP class. | |
string | getDefaultGroup() Returns the name of the default group for this class. | |
$this | addPropertyConstraint(string $property, Constraint $constraint) Adds a constraint to the given property. | |
$this | addPropertyConstraints(string $property, array $constraints) | |
$this | addGetterConstraint(string $property, Constraint $constraint) Adds a constraint to the getter of the given property. | |
$this | addGetterMethodConstraint(string $property, string $method, Constraint $constraint) Adds a constraint to the getter of the given property. | |
$this | addGetterConstraints(string $property, array $constraints) | |
$this | addGetterMethodConstraints(string $property, string $method, array $constraints) | |
mergeConstraints(ClassMetadata $source) Merges the constraints of the given metadata into this object. | ||
bool | hasPropertyMetadata(string $property) Check if there's any metadata attached to the given named property. | |
PropertyMetadataInterface[] | getPropertyMetadata(string $property) Returns all metadata instances for the given named property. | |
string[] | getConstrainedProperties() Returns the names of all constrained properties. | |
$this | setGroupSequence(string[]|GroupSequence $groupSequence) Sets the default group sequence for this class. | |
bool | hasGroupSequence() Returns whether the "Default" group is overridden by a group sequence. | |
GroupSequence|null | getGroupSequence() Returns the group sequence that overrides the "Default" group for this class. | |
ReflectionClass | getReflectionClass() Returns a ReflectionClass instance for this class. | |
setGroupSequenceProvider(bool $active) Sets whether a group sequence provider should be used. | ||
bool | isGroupSequenceProvider() Returns whether the "Default" group is overridden by a dynamic group sequence obtained by the validated objects. |
Returns the names of the properties that should be serialized.
string[] |
Clones this object.
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:
Constraint | $constraint |
$this |
ConstraintDefinitionException | When trying to add the {@link Traverse} constraint |
Adds an list of constraints.
array | $constraints | The constraints to add |
$this |
Returns all constraints of this element.
Constraint[] | A list of Constraint instances |
Returns whether this element has any constraints.
bool |
Returns all constraints for a given validation group.
string | $group | The validation group |
Constraint[] | A list of constraint instances |
Class nodes are never cascaded.
{@inheritdoc}
int | The cascading strategy |
Returns the strategy for traversing traversable objects.
int | The traversal strategy |
string | $class |
Returns the name of the backing PHP class.
string | The name of the backing class |
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 "
string | The name of the default group |
Adds a constraint to the given property.
string | $property | The name of the property |
Constraint | $constraint | The constraint |
$this |
string | $property | |
array | $constraints |
$this |
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".
string | $property | The name of the property |
Constraint | $constraint | The constraint |
$this |
Adds a constraint to the getter of the given property.
string | $property | The name of the property |
string | $method | The name of the getter method |
Constraint | $constraint | The constraint |
$this |
string | $property | |
array | $constraints |
$this |
string | $property | |
string | $method | |
array | $constraints |
$this |
Merges the constraints of the given metadata into this object.
ClassMetadata | $source |
Check if there's any metadata attached to the given named property.
string | $property | The property name |
bool |
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).
string | $property | The property name |
PropertyMetadataInterface[] | A list of metadata instances. Empty if no metadata exists for the property. |
Returns the names of all constrained properties.
string[] | A list of property names |
Sets the default group sequence for this class.
string[]|GroupSequence | $groupSequence | An array of group names |
$this |
GroupDefinitionException |
Returns whether the "Default" group is overridden by a group sequence.
If it is, you can access the group sequence with {@link getGroupSequence()}.
bool | Returns true if the "Default" group is overridden |
Returns the group sequence that overrides the "Default" group for this class.
GroupSequence|null | The group sequence or null |
Returns a ReflectionClass instance for this class.
ReflectionClass |
Sets whether a group sequence provider should be used.
bool | $active |
GroupDefinitionException |
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.
bool | Returns true if the "Default" group is overridden by a dynamic group sequence |
© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/Validator/Mapping/ClassMetadata.html