class ClassMetadata extends ClassMetadataInfo (View source)

{@inheritDoc}

Constants

INHERITANCE_TYPE_NONE

NONE means the class does not participate in an inheritance hierarchy and therefore does not need an inheritance mapping type.

INHERITANCE_TYPE_JOINED

JOINED means the class will be persisted according to the rules of Class Table Inheritance.

INHERITANCE_TYPE_SINGLE_TABLE

SINGLE_TABLE means the class will be persisted according to the rules of Single Table Inheritance.

INHERITANCE_TYPE_TABLE_PER_CLASS

TABLE_PER_CLASS means the class will be persisted according to the rules of Concrete Table Inheritance.

GENERATOR_TYPE_AUTO

AUTO means the generator type will depend on what the used platform prefers.

Offers full portability.

GENERATOR_TYPE_SEQUENCE

SEQUENCE means a separate sequence object will be used. Platforms that do not have native sequence support may emulate it. Full portability is currently not guaranteed.

GENERATOR_TYPE_TABLE

TABLE means a separate table is used for id generation.

Offers full portability.

GENERATOR_TYPE_IDENTITY

IDENTITY means an identity column is used for id generation. The database will fill in the id column on insertion. Platforms that do not support native identity columns may emulate them. Full portability is currently not guaranteed.

GENERATOR_TYPE_NONE

NONE means the class does not have a generated id. That means the class must have a natural, manually assigned id.

GENERATOR_TYPE_UUID

UUID means that a UUID/GUID expression is used for id generation. Full portability is currently not guaranteed.

GENERATOR_TYPE_CUSTOM

CUSTOM means that customer will use own ID generator that supposedly work

CHANGETRACKING_DEFERRED_IMPLICIT

DEFERRED_IMPLICIT means that changes of entities are calculated at commit-time by doing a property-by-property comparison with the original data. This will be done for all entities that are in MANAGED state at commit-time.

This is the default change tracking policy.

CHANGETRACKING_DEFERRED_EXPLICIT

DEFERRED_EXPLICIT means that changes of entities are calculated at commit-time by doing a property-by-property comparison with the original data. This will be done only for entities that were explicitly saved (through persist() or a cascade).

CHANGETRACKING_NOTIFY

NOTIFY means that Doctrine relies on the entities sending out notifications when their properties change. Such entity classes must implement the NotifyPropertyChanged interface.

FETCH_LAZY

Specifies that an association is to be fetched when it is first accessed.

FETCH_EAGER

Specifies that an association is to be fetched when the owner of the association is fetched.

FETCH_EXTRA_LAZY

Specifies that an association is to be fetched lazy (on first access) and that commands such as Collection#count, Collection#slice are issued directly against the database if the collection is not yet initialized.

ONE_TO_ONE

Identifies a one-to-one association.

MANY_TO_ONE

Identifies a many-to-one association.

ONE_TO_MANY

Identifies a one-to-many association.

MANY_TO_MANY

Identifies a many-to-many association.

TO_ONE

Combined bitmask for to-one (single-valued) associations.

TO_MANY

Combined bitmask for to-many (collection-valued) associations.

Properties

string $name READ-ONLY: The name of the entity class. from ClassMetadataInfo
string $namespace READ-ONLY: The namespace the entity class is contained in. from ClassMetadataInfo
string $rootEntityName READ-ONLY: The name of the entity class that is at the root of the mapped entity inheritance hierarchy. If the entity is not part of a mapped inheritance hierarchy this is the same as {@link $entityName}. from ClassMetadataInfo
array $customGeneratorDefinition READ-ONLY: The definition of custom generator. Only used for CUSTOM generator type from ClassMetadataInfo
string $customRepositoryClassName The name of the custom repository class used for the entity class. from ClassMetadataInfo
boolean $isMappedSuperclass READ-ONLY: Whether this class describes the mapping of a mapped superclass. from ClassMetadataInfo
array $parentClasses READ-ONLY: The names of the parent classes (ancestors). from ClassMetadataInfo
array $subClasses READ-ONLY: The names of all subclasses (descendants). from ClassMetadataInfo
array $namedQueries READ-ONLY: The named queries allowed to be called directly from Repository. from ClassMetadataInfo
array $namedNativeQueries READ-ONLY: The named native queries allowed to be called directly from Repository. from ClassMetadataInfo
array $sqlResultSetMappings READ-ONLY: The mappings of the results of native SQL queries. from ClassMetadataInfo
array $identifier READ-ONLY: The field names of all fields that are part of the identifier/primary key of the mapped entity class. from ClassMetadataInfo
integer $inheritanceType READ-ONLY: The inheritance mapping type used by the class. from ClassMetadataInfo
int $generatorType READ-ONLY: The Id generator type used by the class. from ClassMetadataInfo
array $fieldMappings READ-ONLY: The field mappings of the class. from ClassMetadataInfo
array $fieldNames READ-ONLY: An array of field names. Used to look up field names from column names. from ClassMetadataInfo
array $columnNames READ-ONLY: A map of field names to column names. Keys are field names and values column names. from ClassMetadataInfo
mixed $discriminatorValue READ-ONLY: The discriminator value of this class. from ClassMetadataInfo
mixed $discriminatorMap READ-ONLY: The discriminator map of all mapped classes in the hierarchy. from ClassMetadataInfo
array $discriminatorColumn READ-ONLY: The definition of the discriminator column used in JOINED and SINGLE_TABLE inheritance mappings. from ClassMetadataInfo
array $table READ-ONLY: The primary table definition. The definition is an array with the following entries: from ClassMetadataInfo
array $lifecycleCallbacks READ-ONLY: The registered lifecycle callbacks for entities of this class. from ClassMetadataInfo
array $entityListeners READ-ONLY: The registered entity listeners. from ClassMetadataInfo
array $associationMappings READ-ONLY: The association mappings of this class. from ClassMetadataInfo
boolean $isIdentifierComposite READ-ONLY: Flag indicating whether the identifier/primary key of the class is composite. from ClassMetadataInfo
boolean $containsForeignIdentifier READ-ONLY: Flag indicating whether the identifier/primary key contains at least one foreign key association. from ClassMetadataInfo
AbstractIdGenerator $idGenerator READ-ONLY: The ID generator used for generating IDs for this class. from ClassMetadataInfo
array $sequenceGeneratorDefinition READ-ONLY: The definition of the sequence generator of this class. Only used for the SEQUENCE generation strategy. from ClassMetadataInfo
array $tableGeneratorDefinition READ-ONLY: The definition of the table generator of this class. Only used for the TABLE generation strategy. from ClassMetadataInfo
integer $changeTrackingPolicy READ-ONLY: The policy used for change-tracking on entities of this class. from ClassMetadataInfo
boolean $isVersioned READ-ONLY: A flag for whether or not instances of this class are to be versioned with optimistic locking. from ClassMetadataInfo
mixed $versionField READ-ONLY: The name of the field which is used for versioning in optimistic locking (if any). from ClassMetadataInfo
ReflectionClass $reflClass The ReflectionClass instance of the mapped class. from ClassMetadataInfo
bool $isReadOnly Is this entity marked as "read-only"? from ClassMetadataInfo
protected NamingStrategy $namingStrategy NamingStrategy determining the default column and table names. from ClassMetadataInfo
ReflectionProperty[] $reflFields The ReflectionProperty instances of the mapped class. from ClassMetadataInfo

Methods

__construct(string $entityName, NamingStrategy $namingStrategy = null)

Initializes a new ClassMetadata instance that will hold the object-relational mapping metadata of the class with the given name.

array
getReflectionProperties()

Gets the ReflectionProperties of the mapped class.

getReflectionProperty(string $name)

Gets a ReflectionProperty for a specific field of the mapped class.

getSingleIdReflectionProperty()

Gets the ReflectionProperty for the single identifier field.

array
getIdentifierValues(object $entity)

Extracts the identifier values of an entity of this class.

void
setIdentifierValues(object $entity, array $id)

Populates the entity identifier of an entity.

void
setFieldValue(object $entity, string $field, mixed $value)

Sets the specified field to the specified value on the given entity.

mixed
getFieldValue(object $entity, string $field)

Gets the specified field's value off the given entity.

string
__toString()

Creates a string representation of this instance.

array
__sleep()

Determines which fields get serialized.

object
newInstance()

Creates a new instance of the mapped class, without invoking the constructor.

void
wakeupReflection(ReflectionService $reflService)

Restores some state that can not be serialized/unserialized.

void
initializeReflection(ReflectionService $reflService)

Initializes a new ClassMetadata instance that will hold the object-relational mapping metadata of the class with the given name.

void
validateIdentifier()

Validates Identifier.

void
validateAssociations()

Validates association targets actually exist.

void
validateLifecycleCallbacks(ReflectionService $reflService)

Validates lifecycle callbacks.

getReflectionClass()

{@inheritDoc}

void
setChangeTrackingPolicy(integer $policy)

Sets the change tracking policy used by this class.

boolean
isChangeTrackingDeferredExplicit()

Whether the change tracking policy of this class is "deferred explicit".

boolean
isChangeTrackingDeferredImplicit()

Whether the change tracking policy of this class is "deferred implicit".

boolean
isChangeTrackingNotify()

Whether the change tracking policy of this class is "notify".

boolean
isIdentifier(string $fieldName)

Checks whether a field is part of the identifier/primary key field(s).

boolean
isUniqueField(string $fieldName)

Checks if the field is unique.

boolean
isNullable(string $fieldName)

Checks if the field is not null.

string
getColumnName(string $fieldName)

Gets a column name for a field name.

array
getFieldMapping(string $fieldName)

Gets the mapping of a (regular) field that holds some data but not a reference to another object.

array
getAssociationMapping(string $fieldName)

Gets the mapping of an association.

array
getAssociationMappings()

Gets all association mappings of the class.

string
getFieldName(string $columnName)

Gets the field name for a column name.

string
getNamedQuery(string $queryName)

Gets the named query.

array
getNamedQueries()

Gets all named queries of the class.

array
getNamedNativeQuery(string $queryName)

Gets the named native query.

array
getNamedNativeQueries()

Gets all named native queries of the class.

array
getSqlResultSetMapping(string $name)

Gets the result set mapping.

array
getSqlResultSetMappings()

Gets all sql result set mappings of the class.

array
_validateAndCompleteFieldMapping(array $mapping)

Validates & completes the given field mapping.

array
_validateAndCompleteAssociationMapping(array $mapping)

Validates & completes the basic mapping information that is common to all association mappings (one-to-one, many-ot-one, one-to-many, many-to-many).

array
_validateAndCompleteOneToOneMapping(array $mapping)

Validates & completes a one-to-one association mapping.

array
_validateAndCompleteOneToManyMapping(array $mapping)

Validates & completes a one-to-many association mapping.

array
_validateAndCompleteManyToManyMapping(array $mapping)

Validates & completes a many-to-many association mapping.

string
getSingleIdentifierFieldName()

Gets the name of the single id field. Note that this only works on entity classes that have a single-field pk.

string
getSingleIdentifierColumnName()

Gets the column name of the single id column. Note that this only works on entity classes that have a single-field pk.

void
setIdentifier(array $identifier)

INTERNAL: Sets the mapped identifier/primary key fields of this class.

getIdentifier()

{@inheritDoc}

hasField($fieldName)

{@inheritDoc}

array
getColumnNames(array $fieldNames = null)

Gets an array containing all the column names.

array
getIdentifierColumnNames()

Returns an array with all the identifier column names.

void
setIdGeneratorType(int $generatorType)

Sets the type of Id generator to use for the mapped class.

boolean
usesIdGenerator()

Checks whether the mapped class uses an Id generator.

boolean
isInheritanceTypeNone()

No description

boolean
isInheritanceTypeJoined()

Checks whether the mapped class uses the JOINED inheritance mapping strategy.

boolean
isInheritanceTypeSingleTable()

Checks whether the mapped class uses the SINGLE_TABLE inheritance mapping strategy.

boolean
isInheritanceTypeTablePerClass()

Checks whether the mapped class uses the TABLE_PER_CLASS inheritance mapping strategy.

boolean
isIdGeneratorIdentity()

Checks whether the class uses an identity column for the Id generation.

boolean
isIdGeneratorSequence()

Checks whether the class uses a sequence for id generation.

boolean
isIdGeneratorTable()

Checks whether the class uses a table for id generation.

boolean
isIdentifierNatural()

Checks whether the class has a natural identifier/pk (which means it does not use any Id generator.

boolean
isIdentifierUuid()

Checks whether the class use a UUID for id generation.

Type|string|null
getTypeOfField(string $fieldName)

Gets the type of a field.

Type
getTypeOfColumn(string $columnName)

Gets the type of a column.

string
getTableName()

Gets the name of the primary table.

string
getTemporaryIdTableName()

Gets the table name to use for temporary identifier tables of this class.

void
setSubclasses(array $subclasses)

Sets the mapped subclasses of this class.

void
setParentClasses(array $classNames)

Sets the parent class names.

void
setInheritanceType(integer $type)

Sets the inheritance type used by the class and its subclasses.

void
setAssociationOverride(string $fieldName, array $overrideMapping)

Sets the association to override association mapping of property for an entity relationship.

void
setAttributeOverride(string $fieldName, array $overrideMapping)

Sets the override for a mapped field.

bool
isInheritedField(string $fieldName)

Checks whether a mapped field is inherited from an entity superclass.

bool
isRootEntity()

Checks if this entity is the root in any entity-inheritance-hierarchy.

boolean
isInheritedAssociation(string $fieldName)

Checks whether a mapped association field is inherited from a superclass.

void
setTableName(string $tableName) deprecated

Sets the name of the primary table the class is mapped to.

void
setPrimaryTable(array $table)

Sets the primary table definition. The provided array supports the following structure:

void
mapField(array $mapping)

Adds a mapped field to the class.

void
addInheritedAssociationMapping(array $mapping)

INTERNAL: Adds an association mapping without completing/validating it.

void
addInheritedFieldMapping(array $fieldMapping)

INTERNAL: Adds a field mapping without completing/validating it.

void
addNamedQuery(array $queryMapping)

INTERNAL: Adds a named query to this class.

void
addNamedNativeQuery(array $queryMapping)

INTERNAL: Adds a named native query to this class.

void
addSqlResultSetMapping(array $resultMapping)

INTERNAL: Adds a sql result set mapping to this class.

void
mapOneToOne(array $mapping)

Adds a one-to-one mapping.

void
mapOneToMany(array $mapping)

Adds a one-to-many mapping.

void
mapManyToOne(array $mapping)

Adds a many-to-one mapping.

void
mapManyToMany(array $mapping)

Adds a many-to-many mapping.

void
_storeAssociationMapping(array $assocMapping)

Stores the association mapping.

void
setCustomRepositoryClass(string $repositoryClassName)

Registers a custom repository class for the entity class.

void
invokeLifecycleCallbacks(string $lifecycleEvent, object $entity) deprecated

Dispatches the lifecycle event of the given entity to the registered lifecycle callbacks and lifecycle listeners.

boolean
hasLifecycleCallbacks(string $lifecycleEvent)

Whether the class has any attached lifecycle listeners or callbacks for a lifecycle event.

array
getLifecycleCallbacks(string $event)

Gets the registered lifecycle callbacks for an event.

void
addLifecycleCallback(string $callback, string $event)

Adds a lifecycle callback for entities of this class.

void
setLifecycleCallbacks(array $callbacks)

Sets the lifecycle callbacks for entities of this class.

addEntityListener(string $eventName, string $class, string $method)

Adds a entity listener for entities of this class.

void
setDiscriminatorColumn(array $columnDef)

Sets the discriminator column definition.

void
setDiscriminatorMap(array $map)

Sets the discriminator values used by this class.

void
addDiscriminatorMapClass(string $name, string $className)

Adds one entry of the discriminator map with a new class and corresponding name.

boolean
hasNamedQuery(string $queryName)

Checks whether the class has a named query with the given query name.

boolean
hasNamedNativeQuery(string $queryName)

Checks whether the class has a named native query with the given query name.

boolean
hasSqlResultSetMapping(string $name)

Checks whether the class has a named native query with the given query name.

hasAssociation($fieldName)

{@inheritDoc}

isSingleValuedAssociation($fieldName)

{@inheritDoc}

isCollectionValuedAssociation($fieldName)

{@inheritDoc}

bool
isAssociationWithSingleJoinColumn(string $fieldName)

Is this an association that only has a single join column?

string
getSingleAssociationJoinColumnName(string $fieldName)

Returns the single association join column (if any).

string
getSingleAssociationReferencedJoinColumnName(string $fieldName)

Returns the single association referenced join column name (if any).

string
getFieldForColumn(string $columnName)

Used to retrieve a fieldname for either field or association from a given column.

void
setIdGenerator(AbstractIdGenerator $generator)

Sets the ID generator used to generate IDs for instances of this class.

void
setCustomGeneratorDefinition(array $definition)

Sets definition.

void
setSequenceGeneratorDefinition(array $definition)

Sets the definition of the sequence ID generator for this class.

void
setVersionMapping(array $mapping)

Sets the version field mapping used for versioning. Sets the default value to use depending on the column type.

void
setVersioned(boolean $bool)

Sets whether this class is to be versioned for optimistic locking.

void
setVersionField(string $versionField)

Sets the name of the field that is to be used for versioning if this class is versioned for optimistic locking.

void
markReadOnly()

Marks this class as read only, no change tracking is applied to it.

getFieldNames()

{@inheritDoc}

getAssociationNames()

{@inheritDoc}

getAssociationTargetClass($assocName)

{@inheritDoc}

getName()

{@inheritDoc}

array
getQuotedIdentifierColumnNames(AbstractPlatform $platform) deprecated

Gets the (possibly quoted) identifier column names for safe use in an SQL statement.

string
getQuotedColumnName(string $field, AbstractPlatform $platform) deprecated

Gets the (possibly quoted) column name of a mapped field for safe use in an SQL statement.

string
getQuotedTableName(AbstractPlatform $platform) deprecated

Gets the (possibly quoted) primary table name of this class for safe use in an SQL statement.

string
getQuotedJoinTableName(array $assoc, AbstractPlatform $platform) deprecated

Gets the (possibly quoted) name of the join table.

isAssociationInverseSide($fieldName)

{@inheritDoc}

getAssociationMappedByTargetField($fieldName)

{@inheritDoc}

array
getAssociationsByTargetClass(string $targetClass)

No description

string
fullyQualifiedClassName(string $className)

No description

mixed
getMetadataValue(string $name)

No description

Details

__construct(string $entityName, NamingStrategy $namingStrategy = null)

Initializes a new ClassMetadata instance that will hold the object-relational mapping metadata of the class with the given name.

Parameters

string $entityName The name of the entity class the new instance is used for.
NamingStrategy $namingStrategy

array getReflectionProperties()

Gets the ReflectionProperties of the mapped class.

Return Value

array An array of ReflectionProperty instances.

ReflectionProperty getReflectionProperty(string $name)

Gets a ReflectionProperty for a specific field of the mapped class.

Parameters

string $name

Return Value

ReflectionProperty

ReflectionProperty getSingleIdReflectionProperty()

Gets the ReflectionProperty for the single identifier field.

Return Value

ReflectionProperty

Exceptions

BadMethodCallException If the class has a composite identifier.

array getIdentifierValues(object $entity)

Extracts the identifier values of an entity of this class.

For composite identifiers, the identifier values are returned as an array with the same order as the field order in {@link identifier}.

Parameters

object $entity

Return Value

array

void setIdentifierValues(object $entity, array $id)

Populates the entity identifier of an entity.

Parameters

object $entity
array $id

Return Value

void

void setFieldValue(object $entity, string $field, mixed $value)

Sets the specified field to the specified value on the given entity.

Parameters

object $entity
string $field
mixed $value

Return Value

void

mixed getFieldValue(object $entity, string $field)

Gets the specified field's value off the given entity.

Parameters

object $entity
string $field

Return Value

mixed

string __toString()

Creates a string representation of this instance.

Return Value

string The string representation of this instance.

array __sleep()

Determines which fields get serialized.

It is only serialized what is necessary for best unserialization performance. That means any metadata properties that are not set or empty or simply have their default value are NOT serialized.

Parts that are also NOT serialized because they can not be properly unserialized: - reflClass (ReflectionClass) - reflFields (ReflectionProperty array)

Return Value

array The names of all the fields that should be serialized.

object newInstance()

Creates a new instance of the mapped class, without invoking the constructor.

Return Value

object

void wakeupReflection(ReflectionService $reflService)

Restores some state that can not be serialized/unserialized.

Parameters

ReflectionService $reflService

Return Value

void

void initializeReflection(ReflectionService $reflService)

Initializes a new ClassMetadata instance that will hold the object-relational mapping metadata of the class with the given name.

Parameters

ReflectionService $reflService The reflection service.

Return Value

void

void validateIdentifier()

Validates Identifier.

Return Value

void

Exceptions

MappingException

void validateAssociations()

Validates association targets actually exist.

Return Value

void

Exceptions

MappingException

void validateLifecycleCallbacks(ReflectionService $reflService)

Validates lifecycle callbacks.

Parameters

ReflectionService $reflService

Return Value

void

Exceptions

MappingException

getReflectionClass()

{@inheritDoc}

void setChangeTrackingPolicy(integer $policy)

Sets the change tracking policy used by this class.

Parameters

integer $policy

Return Value

void

boolean isChangeTrackingDeferredExplicit()

Whether the change tracking policy of this class is "deferred explicit".

Return Value

boolean

boolean isChangeTrackingDeferredImplicit()

Whether the change tracking policy of this class is "deferred implicit".

Return Value

boolean

boolean isChangeTrackingNotify()

Whether the change tracking policy of this class is "notify".

Return Value

boolean

boolean isIdentifier(string $fieldName)

Checks whether a field is part of the identifier/primary key field(s).

Parameters

string $fieldName The field name.

Return Value

boolean TRUE if the field is part of the table identifier/primary key field(s), FALSE otherwise.

boolean isUniqueField(string $fieldName)

Checks if the field is unique.

Parameters

string $fieldName The field name.

Return Value

boolean TRUE if the field is unique, FALSE otherwise.

boolean isNullable(string $fieldName)

Checks if the field is not null.

Parameters

string $fieldName The field name.

Return Value

boolean TRUE if the field is not null, FALSE otherwise.

string getColumnName(string $fieldName)

Gets a column name for a field name.

If the column name for the field cannot be found, the given field name is returned.

Parameters

string $fieldName The field name.

Return Value

string The column name.

array getFieldMapping(string $fieldName)

Gets the mapping of a (regular) field that holds some data but not a reference to another object.

Parameters

string $fieldName The field name.

Return Value

array The field mapping.

Exceptions

MappingException

array getAssociationMapping(string $fieldName)

Gets the mapping of an association.

Parameters

string $fieldName The field name that represents the association in the object model.

Return Value

array The mapping.

Exceptions

MappingException

See also

ClassMetadataInfo::$associationMappings

array getAssociationMappings()

Gets all association mappings of the class.

Return Value

array

string getFieldName(string $columnName)

Gets the field name for a column name.

If no field name can be found the column name is returned.

Parameters

string $columnName The column name.

Return Value

string The column alias.

string getNamedQuery(string $queryName)

Gets the named query.

Parameters

string $queryName The query name.

Return Value

string

Exceptions

MappingException

See also

ClassMetadataInfo::$namedQueries

array getNamedQueries()

Gets all named queries of the class.

Return Value

array

array getNamedNativeQuery(string $queryName)

Gets the named native query.

Parameters

string $queryName The query name.

Return Value

array

Exceptions

MappingException

See also

ClassMetadataInfo::$namedNativeQueries

array getNamedNativeQueries()

Gets all named native queries of the class.

Return Value

array

array getSqlResultSetMapping(string $name)

Gets the result set mapping.

Parameters

string $name The result set mapping name.

Return Value

array

Exceptions

MappingException

See also

ClassMetadataInfo::$sqlResultSetMappings

array getSqlResultSetMappings()

Gets all sql result set mappings of the class.

Return Value

array

protected array _validateAndCompleteFieldMapping(array $mapping)

Validates & completes the given field mapping.

Parameters

array $mapping The field mapping to validate & complete.

Return Value

array The validated and completed field mapping.

Exceptions

MappingException

protected array _validateAndCompleteAssociationMapping(array $mapping)

Validates & completes the basic mapping information that is common to all association mappings (one-to-one, many-ot-one, one-to-many, many-to-many).

Parameters

array $mapping The mapping.

Return Value

array The updated mapping.

Exceptions

MappingException If something is wrong with the mapping.

protected array _validateAndCompleteOneToOneMapping(array $mapping)

Validates & completes a one-to-one association mapping.

Parameters

array $mapping The mapping to validate & complete.

Return Value

array The validated & completed mapping.

Exceptions

RuntimeException
MappingException

protected array _validateAndCompleteOneToManyMapping(array $mapping)

Validates & completes a one-to-many association mapping.

Parameters

array $mapping The mapping to validate and complete.

Return Value

array The validated and completed mapping.

Exceptions

MappingException
InvalidArgumentException

protected array _validateAndCompleteManyToManyMapping(array $mapping)

Validates & completes a many-to-many association mapping.

Parameters

array $mapping The mapping to validate & complete.

Return Value

array The validated & completed mapping.

Exceptions

InvalidArgumentException

getIdentifierFieldNames()

{@inheritDoc}

string getSingleIdentifierFieldName()

Gets the name of the single id field. Note that this only works on entity classes that have a single-field pk.

Return Value

string

Exceptions

MappingException If the class has a composite primary key.

string getSingleIdentifierColumnName()

Gets the column name of the single id column. Note that this only works on entity classes that have a single-field pk.

Return Value

string

Exceptions

MappingException If the class has a composite primary key.

void setIdentifier(array $identifier)

INTERNAL: Sets the mapped identifier/primary key fields of this class.

Mainly used by the ClassMetadataFactory to assign inherited identifiers.

Parameters

array $identifier

Return Value

void

getIdentifier()

{@inheritDoc}

hasField($fieldName)

{@inheritDoc}

Parameters

$fieldName

array getColumnNames(array $fieldNames = null)

Gets an array containing all the column names.

Parameters

array $fieldNames

Return Value

array

array getIdentifierColumnNames()

Returns an array with all the identifier column names.

Return Value

array

void setIdGeneratorType(int $generatorType)

Sets the type of Id generator to use for the mapped class.

Parameters

int $generatorType

Return Value

void

boolean usesIdGenerator()

Checks whether the mapped class uses an Id generator.

Return Value

boolean TRUE if the mapped class uses an Id generator, FALSE otherwise.

boolean isInheritanceTypeNone()

Return Value

boolean

boolean isInheritanceTypeJoined()

Checks whether the mapped class uses the JOINED inheritance mapping strategy.

Return Value

boolean TRUE if the class participates in a JOINED inheritance mapping, FALSE otherwise.

boolean isInheritanceTypeSingleTable()

Checks whether the mapped class uses the SINGLE_TABLE inheritance mapping strategy.

Return Value

boolean TRUE if the class participates in a SINGLE_TABLE inheritance mapping, FALSE otherwise.

boolean isInheritanceTypeTablePerClass()

Checks whether the mapped class uses the TABLE_PER_CLASS inheritance mapping strategy.

Return Value

boolean TRUE if the class participates in a TABLE_PER_CLASS inheritance mapping, FALSE otherwise.

boolean isIdGeneratorIdentity()

Checks whether the class uses an identity column for the Id generation.

Return Value

boolean TRUE if the class uses the IDENTITY generator, FALSE otherwise.

boolean isIdGeneratorSequence()

Checks whether the class uses a sequence for id generation.

Return Value

boolean TRUE if the class uses the SEQUENCE generator, FALSE otherwise.

boolean isIdGeneratorTable()

Checks whether the class uses a table for id generation.

Return Value

boolean TRUE if the class uses the TABLE generator, FALSE otherwise.

boolean isIdentifierNatural()

Checks whether the class has a natural identifier/pk (which means it does not use any Id generator.

Return Value

boolean

boolean isIdentifierUuid()

Checks whether the class use a UUID for id generation.

Return Value

boolean

Type|string|null getTypeOfField(string $fieldName)

Gets the type of a field.

Parameters

string $fieldName

Return Value

Type|string|null

Type getTypeOfColumn(string $columnName)

Gets the type of a column.

Parameters

string $columnName

Return Value

Type

string getTableName()

Gets the name of the primary table.

Return Value

string

string getTemporaryIdTableName()

Gets the table name to use for temporary identifier tables of this class.

Return Value

string

void setSubclasses(array $subclasses)

Sets the mapped subclasses of this class.

Parameters

array $subclasses The names of all mapped subclasses.

Return Value

void

void setParentClasses(array $classNames)

Sets the parent class names.

Assumes that the class names in the passed array are in the order: directParent -> directParentParent -> directParentParentParent ... -> root.

Parameters

array $classNames

Return Value

void

void setInheritanceType(integer $type)

Sets the inheritance type used by the class and its subclasses.

Parameters

integer $type

Return Value

void

Exceptions

MappingException

void setAssociationOverride(string $fieldName, array $overrideMapping)

Sets the association to override association mapping of property for an entity relationship.

Parameters

string $fieldName
array $overrideMapping

Return Value

void

Exceptions

MappingException

void setAttributeOverride(string $fieldName, array $overrideMapping)

Sets the override for a mapped field.

Parameters

string $fieldName
array $overrideMapping

Return Value

void

Exceptions

MappingException

bool isInheritedField(string $fieldName)

Checks whether a mapped field is inherited from an entity superclass.

Parameters

string $fieldName

Return Value

bool TRUE if the field is inherited, FALSE otherwise.

bool isRootEntity()

Checks if this entity is the root in any entity-inheritance-hierarchy.

Return Value

bool

boolean isInheritedAssociation(string $fieldName)

Checks whether a mapped association field is inherited from a superclass.

Parameters

string $fieldName

Return Value

boolean TRUE if the field is inherited, FALSE otherwise.

void setTableName(string $tableName) deprecated

deprecated Use {@link setPrimaryTable}.

Sets the name of the primary table the class is mapped to.

Parameters

string $tableName The table name.

Return Value

void

void setPrimaryTable(array $table)

Sets the primary table definition. The provided array supports the following structure:

name => (optional, defaults to class name) indexes => array of indexes (optional) uniqueConstraints => array of constraints (optional)

If a key is omitted, the current value is kept.

Parameters

array $table The table description.

Return Value

void

void mapField(array $mapping)

Adds a mapped field to the class.

Parameters

array $mapping The field mapping.

Return Value

void

Exceptions

MappingException

void addInheritedAssociationMapping(array $mapping)

INTERNAL: Adds an association mapping without completing/validating it.

This is mainly used to add inherited association mappings to derived classes.

Parameters

array $mapping

Return Value

void

Exceptions

MappingException

void addInheritedFieldMapping(array $fieldMapping)

INTERNAL: Adds a field mapping without completing/validating it.

This is mainly used to add inherited field mappings to derived classes.

Parameters

array $fieldMapping

Return Value

void

void addNamedQuery(array $queryMapping)

INTERNAL: Adds a named query to this class.

Parameters

array $queryMapping

Return Value

void

Exceptions

MappingException

void addNamedNativeQuery(array $queryMapping)

INTERNAL: Adds a named native query to this class.

Parameters

array $queryMapping

Return Value

void

Exceptions

MappingException

void addSqlResultSetMapping(array $resultMapping)

INTERNAL: Adds a sql result set mapping to this class.

Parameters

array $resultMapping

Return Value

void

Exceptions

MappingException

void mapOneToOne(array $mapping)

Adds a one-to-one mapping.

Parameters

array $mapping The mapping.

Return Value

void

void mapOneToMany(array $mapping)

Adds a one-to-many mapping.

Parameters

array $mapping The mapping.

Return Value

void

void mapManyToOne(array $mapping)

Adds a many-to-one mapping.

Parameters

array $mapping The mapping.

Return Value

void

void mapManyToMany(array $mapping)

Adds a many-to-many mapping.

Parameters

array $mapping The mapping.

Return Value

void

protected void _storeAssociationMapping(array $assocMapping)

Stores the association mapping.

Parameters

array $assocMapping

Return Value

void

Exceptions

MappingException

void setCustomRepositoryClass(string $repositoryClassName)

Registers a custom repository class for the entity class.

Parameters

string $repositoryClassName The class name of the custom mapper.

Return Value

void

void invokeLifecycleCallbacks(string $lifecycleEvent, object $entity) deprecated

deprecated Deprecated since version 2.4 in favor of \Doctrine\ORM\Event\ListenersInvoker

Dispatches the lifecycle event of the given entity to the registered lifecycle callbacks and lifecycle listeners.

Parameters

string $lifecycleEvent The lifecycle event.
object $entity The Entity on which the event occurred.

Return Value

void

boolean hasLifecycleCallbacks(string $lifecycleEvent)

Whether the class has any attached lifecycle listeners or callbacks for a lifecycle event.

Parameters

string $lifecycleEvent

Return Value

boolean

array getLifecycleCallbacks(string $event)

Gets the registered lifecycle callbacks for an event.

Parameters

string $event

Return Value

array

void addLifecycleCallback(string $callback, string $event)

Adds a lifecycle callback for entities of this class.

Parameters

string $callback
string $event

Return Value

void

void setLifecycleCallbacks(array $callbacks)

Sets the lifecycle callbacks for entities of this class.

Any previously registered callbacks are overwritten.

Parameters

array $callbacks

Return Value

void

addEntityListener(string $eventName, string $class, string $method)

Adds a entity listener for entities of this class.

Parameters

string $eventName The entity lifecycle event.
string $class The listener class.
string $method The listener callback method.

Exceptions

MappingException

void setDiscriminatorColumn(array $columnDef)

Sets the discriminator column definition.

Parameters

array $columnDef

Return Value

void

Exceptions

MappingException

See also

getDiscriminatorColumn()

void setDiscriminatorMap(array $map)

Sets the discriminator values used by this class.

Used for JOINED and SINGLE_TABLE inheritance mapping strategies.

Parameters

array $map

Return Value

void

void addDiscriminatorMapClass(string $name, string $className)

Adds one entry of the discriminator map with a new class and corresponding name.

Parameters

string $name
string $className

Return Value

void

Exceptions

MappingException

boolean hasNamedQuery(string $queryName)

Checks whether the class has a named query with the given query name.

Parameters

string $queryName

Return Value

boolean

boolean hasNamedNativeQuery(string $queryName)

Checks whether the class has a named native query with the given query name.

Parameters

string $queryName

Return Value

boolean

boolean hasSqlResultSetMapping(string $name)

Checks whether the class has a named native query with the given query name.

Parameters

string $name

Return Value

boolean

hasAssociation($fieldName)

{@inheritDoc}

Parameters

$fieldName

isSingleValuedAssociation($fieldName)

{@inheritDoc}

Parameters

$fieldName

isCollectionValuedAssociation($fieldName)

{@inheritDoc}

Parameters

$fieldName

bool isAssociationWithSingleJoinColumn(string $fieldName)

Is this an association that only has a single join column?

Parameters

string $fieldName

Return Value

bool

string getSingleAssociationJoinColumnName(string $fieldName)

Returns the single association join column (if any).

Parameters

string $fieldName

Return Value

string

Exceptions

MappingException

string getSingleAssociationReferencedJoinColumnName(string $fieldName)

Returns the single association referenced join column name (if any).

Parameters

string $fieldName

Return Value

string

Exceptions

MappingException

string getFieldForColumn(string $columnName)

Used to retrieve a fieldname for either field or association from a given column.

This method is used in foreign-key as primary-key contexts.

Parameters

string $columnName

Return Value

string

Exceptions

MappingException

void setIdGenerator(AbstractIdGenerator $generator)

Sets the ID generator used to generate IDs for instances of this class.

Parameters

AbstractIdGenerator $generator

Return Value

void

void setCustomGeneratorDefinition(array $definition)

Sets definition.

Parameters

array $definition

Return Value

void

void setSequenceGeneratorDefinition(array $definition)

Sets the definition of the sequence ID generator for this class.

The definition must have the following structure: array( 'sequenceName' => 'name', 'allocationSize' => 20, 'initialValue' => 1 'quoted' => 1 )

Parameters

array $definition

Return Value

void

void setVersionMapping(array $mapping)

Sets the version field mapping used for versioning. Sets the default value to use depending on the column type.

Parameters

array $mapping The version field mapping array.

Return Value

void

Exceptions

MappingException

void setVersioned(boolean $bool)

Sets whether this class is to be versioned for optimistic locking.

Parameters

boolean $bool

Return Value

void

void setVersionField(string $versionField)

Sets the name of the field that is to be used for versioning if this class is versioned for optimistic locking.

Parameters

string $versionField

Return Value

void

void markReadOnly()

Marks this class as read only, no change tracking is applied to it.

Return Value

void

getFieldNames()

{@inheritDoc}

getAssociationNames()

{@inheritDoc}

getAssociationTargetClass($assocName)

{@inheritDoc}

Parameters

$assocName

Exceptions

InvalidArgumentException

getName()

{@inheritDoc}

array getQuotedIdentifierColumnNames(AbstractPlatform $platform) deprecated

deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy

Gets the (possibly quoted) identifier column names for safe use in an SQL statement.

Parameters

AbstractPlatform $platform

Return Value

array

string getQuotedColumnName(string $field, AbstractPlatform $platform) deprecated

deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy

Gets the (possibly quoted) column name of a mapped field for safe use in an SQL statement.

Parameters

string $field
AbstractPlatform $platform

Return Value

string

string getQuotedTableName(AbstractPlatform $platform) deprecated

deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy

Gets the (possibly quoted) primary table name of this class for safe use in an SQL statement.

Parameters

AbstractPlatform $platform

Return Value

string

string getQuotedJoinTableName(array $assoc, AbstractPlatform $platform) deprecated

deprecated Deprecated since version 2.3 in favor of \Doctrine\ORM\Mapping\QuoteStrategy

Gets the (possibly quoted) name of the join table.

Parameters

array $assoc
AbstractPlatform $platform

Return Value

string

isAssociationInverseSide($fieldName)

{@inheritDoc}

Parameters

$fieldName

getAssociationMappedByTargetField($fieldName)

{@inheritDoc}

Parameters

$fieldName

array getAssociationsByTargetClass(string $targetClass)

Parameters

string $targetClass

Return Value

array

string fullyQualifiedClassName(string $className)

Parameters

string $className

Return Value

string

mixed getMetadataValue(string $name)

Parameters

string $name

Return Value

mixed