Documentation

ClassMetadata extends GenericMetadata
in package
implements ClassMetadataInterface

Default implementation of {@link ClassMetadataInterface}.

This class supports serialization and cloning.

Tags
author

Bernhard Schussek bschussek@gmail.com

author

Fabien Potencier fabien@symfony.com

Table of Contents

Interfaces

ClassMetadataInterface
Stores all metadata needed for validating objects of specific class.

Properties

$reflClass  : ReflectionClass

Methods

__clone()  : mixed
Clones this object.
__construct()  : mixed
__sleep()  : array<string|int, string>
Returns the names of the properties that should be serialized.
addConstraint()  : $this
Adds a constraint.
addConstraints()  : $this
Adds an list of constraints.
addGetterConstraint()  : $this
Adds a constraint to the getter of the given property.
addGetterConstraints()  : $this
addGetterMethodConstraint()  : $this
Adds a constraint to the getter of the given property.
addGetterMethodConstraints()  : $this
addPropertyConstraint()  : $this
Adds a constraint to the given property.
addPropertyConstraints()  : $this
findConstraints()  : array<string|int, Constraint>
Returns all constraints for a given validation group.
getAutoMappingStrategy()  : int
getCascadingStrategy()  : int
Returns the strategy for cascading objects.
getClassName()  : string
Returns the name of the backing PHP class.
getConstrainedProperties()  : array<string|int, string>
Returns the names of all constrained properties.
getConstraints()  : array<string|int, Constraint>
Returns all constraints of this element.
getDefaultGroup()  : string
Returns the name of the default group for this class.
getGroupSequence()  : GroupSequence|null
Returns the group sequence that overrides the "Default" group for this class.
getPropertyMetadata()  : array<string|int, PropertyMetadataInterface>
Returns all metadata instances for the given named property.
getReflectionClass()  : ReflectionClass
Returns a ReflectionClass instance for this class.
getTraversalStrategy()  : int
Returns the strategy for traversing traversable objects.
hasConstraints()  : bool
Returns whether this element has any constraints.
hasGroupSequence()  : bool
Returns whether the "Default" group is overridden by a group sequence.
hasPropertyMetadata()  : bool
Check if there's any metadata attached to the given named property.
isGroupSequenceProvider()  : bool
Returns whether the "Default" group is overridden by a dynamic group sequence obtained by the validated objects.
mergeConstraints()  : mixed
Merges the constraints of the given metadata into this object.
setGroupSequence()  : $this
Sets the default group sequence for this class.
setGroupSequenceProvider()  : mixed
Sets whether a group sequence provider should be used.
addPropertyMetadata()  : mixed
checkConstraint()  : mixed

Properties

Methods

__construct()

public __construct(string $class) : mixed
Parameters
$class : string

__sleep()

Returns the names of the properties that should be serialized.

public __sleep() : array<string|int, string>
Return values
array<string|int, string>

addConstraint()

Adds a constraint.

public addConstraint(Constraint $constraint) : $this

If the constraint is added, the cascading strategy will be changed to .

If the constraint is added, the traversal strategy will be changed. Depending on the $traverse property of that constraint, the traversal strategy will be set to one of the following:

  • by default
  • if $traverse is disabled
  • if $traverse is enabled
Parameters
$constraint : Constraint
Return values
$this

addConstraints()

Adds an list of constraints.

public addConstraints(array<string|int, Constraint$constraints) : $this
Parameters
$constraints : array<string|int, Constraint>

The constraints to add

Return values
$this

addGetterConstraint()

Adds a constraint to the getter of the given property.

public addGetterConstraint(string $property, Constraint $constraint) : $this

The name of the getter is assumed to be the name of the property with an uppercased first letter and the prefix "get", "is" or "has".

Parameters
$property : string
$constraint : Constraint
Return values
$this

addGetterConstraints()

public addGetterConstraints(string $property, array<string|int, Constraint$constraints) : $this
Parameters
$property : string
$constraints : array<string|int, Constraint>
Return values
$this

addGetterMethodConstraint()

Adds a constraint to the getter of the given property.

public addGetterMethodConstraint(string $property, string $method, Constraint $constraint) : $this
Parameters
$property : string
$method : string
$constraint : Constraint
Return values
$this

addGetterMethodConstraints()

public addGetterMethodConstraints(string $property, string $method, array<string|int, Constraint$constraints) : $this
Parameters
$property : string
$method : string
$constraints : array<string|int, Constraint>
Return values
$this

addPropertyConstraint()

Adds a constraint to the given property.

public addPropertyConstraint(string $property, Constraint $constraint) : $this
Parameters
$property : string
$constraint : Constraint
Return values
$this

addPropertyConstraints()

public addPropertyConstraints(string $property, array<string|int, Constraint$constraints) : $this
Parameters
$property : string
$constraints : array<string|int, Constraint>
Return values
$this

findConstraints()

Returns all constraints for a given validation group.

public findConstraints(string $group) : array<string|int, Constraint>

Aware of the global group (* group).

Parameters
$group : string

The validation group

Return values
array<string|int, Constraint>

getCascadingStrategy()

Returns the strategy for cascading objects.

public getCascadingStrategy() : int
Return values
int

getClassName()

Returns the name of the backing PHP class.

public getClassName() : string
Return values
string

getConstrainedProperties()

Returns the names of all constrained properties.

public getConstrainedProperties() : array<string|int, string>
Return values
array<string|int, string>

getDefaultGroup()

Returns the name of the default group for this class.

public getDefaultGroup() : string

For each class, the group "Default" is an alias for the group "<ClassName>", where <ClassName> 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 "<ClassName>".

Return values
string

getReflectionClass()

Returns a ReflectionClass instance for this class.

public getReflectionClass() : ReflectionClass
Return values
ReflectionClass

getTraversalStrategy()

Returns the strategy for traversing traversable objects.

public getTraversalStrategy() : int
Return values
int

hasConstraints()

Returns whether this element has any constraints.

public hasConstraints() : bool
Return values
bool

hasGroupSequence()

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

public hasGroupSequence() : bool
Return values
bool

hasPropertyMetadata()

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

public hasPropertyMetadata(string $property) : bool
Parameters
$property : string

The property name

Return values
bool

isGroupSequenceProvider()

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

public isGroupSequenceProvider() : bool
Return values
bool

mergeConstraints()

Merges the constraints of the given metadata into this object.

public mergeConstraints(self $source) : mixed
Parameters
$source : self

setGroupSequenceProvider()

Sets whether a group sequence provider should be used.

public setGroupSequenceProvider(bool $active) : mixed
Parameters
$active : bool
Tags
throws
GroupDefinitionException

        
On this page

Search results