Class

Symfony\Component\Validator\Mapping\ClassMetadata

class ClassMetadata extends ElementMetadata

Represents all the configured constraints on a given class.

Properties

$constraints
$constraintsByGroup
$name
$defaultGroup
$members
$properties
$getters
$groupSequence

Methods

array __sleep()

Returns the properties to be serialized

__clone()

Clones this object.

from ElementMetadata
addConstraint(Constraint $constraint)

Adds a constraint to this element.

array getConstraints()

Returns all constraints of this element.

from ElementMetadata
Boolean hasConstraints()

Returns whether this element has any constraints.

from ElementMetadata
array findConstraints(string $group)

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

from ElementMetadata
__construct(string $class)

Constructs a metadata for the given class

string getClassName()

Returns the fully qualified name of the class

string getDefaultGroup()

Returns the name of the default group for this class

ClassMetadata addPropertyConstraint(string $property, Constraint $constraint)

Adds a constraint to the given property.

ClassMetadata addGetterConstraint(string $property, Constraint $constraint)

Adds a constraint to the getter of the given property.

mergeConstraints(ClassMetadata $source)

Merges the constraints of the given metadata into this object.

Boolean hasMemberMetadatas(string $property)

Returns true if metadatas of members is present for the given property.

array getMemberMetadatas(string $property)

Returns all metadatas of members describing the given property

array getConstrainedProperties()

Returns all properties for which constraints are defined.

setGroupSequence(array $groups)

Sets the default group sequence for this class.

Boolean hasGroupSequence()

Returns whether this class has an overridden default group sequence.

array getGroupSequence()

Returns the default group sequence for this class.

ReflectionClass getReflectionClass()

Returns a ReflectionClass instance for this class.

Details

at line 55
public array __sleep()

Returns the properties to be serialized

Return Value

array

in ElementMetadata at line 37
public __clone()

Clones this object.

at line 100
public addConstraint(Constraint $constraint)

Adds a constraint to this element.

Parameters

Constraint $constraint

in ElementMetadata at line 70
public array getConstraints()

Returns all constraints of this element.

Return Value

array An array of Constraint instances

in ElementMetadata at line 80
public Boolean hasConstraints()

Returns whether this element has any constraints.

Return Value

Boolean

in ElementMetadata at line 92
public array findConstraints(string $group)

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

Parameters

string $group The group name

Return Value

array An array with all Constraint instances belonging to the group

at line 39
public __construct(string $class)

Constructs a metadata for the given class

Parameters

string $class

at line 72
public string getClassName()

Returns the fully qualified name of the class

Return Value

string The fully qualified class name

at line 92
public string getDefaultGroup()

Returns the name of the default group for this class

For each class, the group "Default" is an alias for the group "", where is the non-namespaced name of the class. All constraints implicitly or explicitly assigned to group "Default" belong to both of these groups, unless the class defines a group sequence.

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 "".

Return Value

string The name of the default group

at line 122
public ClassMetadata addPropertyConstraint(string $property, Constraint $constraint)

Adds a constraint to the given property.

Parameters

string $property The name of the property
Constraint $constraint The constraint

Return Value

ClassMetadata This object

at line 148
public 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".

Parameters

string $property The name of the property
Constraint $constraint The constraint

Return Value

ClassMetadata This object

at line 168
public mergeConstraints(ClassMetadata $source)

Merges the constraints of the given metadata into this object.

Parameters

ClassMetadata $source The source metadata

at line 216
public Boolean hasMemberMetadatas(string $property)

Returns true if metadatas of members is present for the given property.

Parameters

string $property The name of the property

Return Value

Boolean

at line 228
public array getMemberMetadatas(string $property)

Returns all metadatas of members describing the given property

Parameters

string $property The name of the property

Return Value

array An array of MemberMetadata

at line 238
public array getConstrainedProperties()

Returns all properties for which constraints are defined.

Return Value

array An array of property names

at line 248
public setGroupSequence(array $groups)

Sets the default group sequence for this class.

Parameters

array $groups An array of group names

at line 268
public Boolean hasGroupSequence()

Returns whether this class has an overridden default group sequence.

Return Value

Boolean

at line 278
public array getGroupSequence()

Returns the default group sequence for this class.

Return Value

array An array of group names

at line 288
public ReflectionClass getReflectionClass()

Returns a ReflectionClass instance for this class.

Return Value

ReflectionClass