PHP Class Doctrine\ODM\MongoDB\Mapping\ClassMetadataInfo

Once populated, ClassMetadata instances are usually cached in a serialized form. IMPORTANT NOTE: The fields of this class are only public for 2 reasons: 1) To allow fast READ access. 2) To drastically reduce the size of a serialized instance (private/protected members get the whole class name, namespace inclusive, prepended to every property in the serialized representation).
Since: 1.0
Inheritance: implements Doctrine\Common\Persistence\Mapping\ClassMetadata
Show file Open project: doctrine/mongodb-odm Class Usage Examples

Public Properties

Property Type Description
$alsoLoadMethods array READ-ONLY: Array of fields to also load with a given method.
$associationMappings array Keys are field names and values are mapping definitions.
$changeTrackingPolicy integer READ-ONLY: The policy used for change-tracking on entities of this class.
$collection READ-ONLY: The name of the mongo collection the document is mapped to.
$collectionCapped READ-ONLY: If the collection should be a fixed size.
$collectionMax READ-ONLY: If the collection is fixed size, the maximum number of elements to store in the collection.
$collectionSize READ-ONLY: If the collection is fixed size, its size in bytes.
$customRepositoryClassName string (Optional).
$db READ-ONLY: The name of the mongo database the document is mapped to.
$defaultDiscriminatorValue string READ-ONLY: The default value for discriminatorField in case it's not set in the document
$discriminatorField string READ-ONLY: The definition of the discriminator field used in SINGLE_COLLECTION inheritance mapping.
$discriminatorMap mixed This does only apply to the SINGLE_COLLECTION inheritance mapping strategy where a discriminator field is used.
$discriminatorValue mixed This does only apply to the JOINED and SINGLE_COLLECTION inheritance mapping strategies where a discriminator field is used.
$distance READ-ONLY: The field that stores the calculated distance when performing geo spatial queries.
$fieldMappings array Keys are field names and values are mapping definitions. The mapping definition array has the following values: - fieldName (string) The name of the field in the Document. - id (boolean, optional) Marks the field as the primary key of the document. Multiple fields of an document can have the id attribute, forming a composite key.
$file READ-ONLY: The field that stores a file reference and indicates the document is a file and should be stored on the MongoGridFS.
$generatorOptions array READ-ONLY: The Id generator options.
$generatorType string READ-ONLY: The Id generator type used by the class.
$idGenerator Doctrine\ODM\MongoDB\Id\AbstractIdGenerator READ-ONLY: The ID generator used for generating IDs for this class.
$identifier READ-ONLY: The field name of the document identifier.
$indexes READ-ONLY: The array of indexes for the document collection.
$inheritanceType integer READ-ONLY: The inheritance mapping type used by the class.
$isEmbeddedDocument boolean READ-ONLY: Whether this class describes the mapping of a embedded document.
$isLockable boolean READ-ONLY: A flag for whether or not instances of this class are to allow pessimistic locking.
$isMappedSuperclass boolean READ-ONLY: Whether this class describes the mapping of a mapped superclass.
$isQueryResultDocument boolean READ-ONLY: Whether this class describes the mapping of an aggregation result document.
$isVersioned boolean READ-ONLY: A flag for whether or not instances of this class are to be versioned with optimistic locking.
$lifecycleCallbacks array READ-ONLY: The registered lifecycle callbacks for documents of this class.
$lockField mixed READ-ONLY: The name of the field which is used for locking a document.
$name READ-ONLY: The name of the document class.
$namespace string READ-ONLY: The namespace the document class is contained in.
$parentClasses array READ-ONLY: The names of the parent classes (ancestors).
$reflClass ReflectionClass The ReflectionClass instance of the mapped class.
$reflFields ReflectionProperty[] The ReflectionProperty instances of the mapped class.
$requireIndexes READ-ONLY: Whether or not queries on this document should require indexes.
$rootDocumentName string READ-ONLY: The name of the document class that is at the root of the mapped document inheritance hierarchy. If the document is not part of a mapped inheritance hierarchy this is the same as {@link $documentName}.
$shardKey READ-ONLY: Keys and options describing shard key. Only for sharded collections.
$slaveOkay READ-ONLY: Whether or not reads for this class are okay to read from a slave.
$subClasses array READ-ONLY: The names of all subclasses (descendants).
$versionField mixed READ-ONLY: The name of the field which is used for versioning in optimistic locking (if any).
$writeConcern READ-ONLY: Describes the level of acknowledgement requested from MongoDB for write operations.

Public Methods

Method Description
__construct ( string $documentName ) Initializes a new ClassMetadata instance that will hold the object-document mapping metadata of the class with the given name.
addIndex ( array $keys, array $options = [] ) Add a index for this Document.
addInheritedAssociationMapping ( array $mapping ) : void INTERNAL: Adds an association mapping without completing/validating it.
addInheritedFieldMapping ( array $fieldMapping ) INTERNAL: Adds a field mapping without completing/validating it.
addLifecycleCallback ( string $callback, string $event ) Adds a lifecycle callback for documents of this class.
getAssociationCollectionClass ( string $assocName ) Retrieve the collectionClass associated with an association
getAssociationMappedByTargetField ( $fieldName ) {@inheritDoc}
getAssociationNames ( ) {@inheritDoc}
getAssociationTargetClass ( $assocName ) {@inheritDoc}
getCollection ( ) : string Get the collection this Document is mapped to.
getCollectionCapped ( ) : boolean Get whether or not the documents collection is capped.
getCollectionMax ( ) : integer Get the collection max.
getCollectionSize ( ) : integer Get the collection size
getDatabase ( ) : string Returns the database this Document is mapped to.
getDatabaseIdentifierValue ( mixed $id ) : mixed Casts the identifier to its database type.
getDistance ( ) : string Returns the distance field name.
getEmbeddedFieldsMappings ( ) : array Gets mappings of fields holding embedded document(s).
getFieldMapping ( string $fieldName ) : array Gets the mapping of a field.
getFieldMappingByDbFieldName ( string $dbFieldName ) : array Gets the field mapping by its DB name.
getFieldNames ( ) {@inheritDoc}
getFieldValue ( object $document, string $field ) : mixed Gets the specified field's value off the given document.
getFile ( ) : string Returns the file field name.
getIdentifier ( ) {@inheritDoc}
getIdentifierFieldNames ( ) {@inheritDoc}
getIdentifierObject ( object $document ) : MongoId Get the document identifier object as a database type.
getIdentifierValue ( object $document ) : mixed Gets the document identifier as a PHP type.
getIdentifierValues ( $object ) {@inheritDoc}
getIndexes ( ) : array Returns the array of indexes for this Document.
getLifecycleCallbacks ( string $event ) : array Gets the registered lifecycle callbacks for an event.
getName ( ) {@inheritDoc}
getNamespace ( ) : string The namespace this Document class belongs to.
getPHPIdentifierValue ( mixed $id ) : mixed Casts the identifier to its portable PHP type.
getReflectionClass ( ) {@inheritDoc}
getReflectionProperties ( ) : array Gets the ReflectionProperties of the mapped class.
getReflectionProperty ( string $name ) : ReflectionProperty Gets a ReflectionProperty for a specific field of the mapped class.
getShardKey ( ) : array
getTypeOfField ( $fieldName ) {@inheritDoc}
getWriteConcern ( ) : string
hasAssociation ( $fieldName ) {@inheritDoc}
hasDiscriminator ( ) : boolean Checks whether the document has a discriminator field and value configured.
hasEmbed ( string $fieldName ) : boolean Checks whether the class has a mapped embed with the given field name.
hasField ( $fieldName ) {@inheritDoc}
hasIndexes ( ) : boolean Checks whether this document has indexes or not.
hasLifecycleCallbacks ( string $event ) : boolean Checks whether the class has callbacks registered for a lifecycle event.
hasReference ( string $fieldName ) : boolean Checks whether the class has a mapped association with the given field name.
hasWriteConcern ( ) : boolean Whether there is a write concern configured for this class.
invokeLifecycleCallbacks ( string $event, object $document, array $arguments = null ) Dispatches the lifecycle event of the given document by invoking all registered callbacks.
isAssociationInverseSide ( $fieldName ) {@inheritDoc}
isChangeTrackingDeferredExplicit ( ) : boolean Whether the change tracking policy of this class is "deferred explicit".
isChangeTrackingDeferredImplicit ( ) : boolean Whether the change tracking policy of this class is "deferred implicit".
isChangeTrackingNotify ( ) : boolean Whether the change tracking policy of this class is "notify".
isCollectionValuedAssociation ( $fieldName ) {@inheritDoc}
isCollectionValuedEmbed ( string $fieldName ) : boolean Checks whether the class has a mapped embedded document for the specified field and if yes, checks whether it is a collection-valued association (to-many).
isCollectionValuedReference ( string $fieldName ) : boolean Checks whether the class has a mapped association for the specified field and if yes, checks whether it is a collection-valued association (to-many).
isFile ( ) : boolean Returns TRUE if this Document is a file to be stored on the MongoGridFS FALSE otherwise.
isIdGeneratorAuto ( ) : boolean Checks whether the class will generate a new \MongoId instance for us.
isIdGeneratorIncrement ( ) : boolean Checks whether the class will use a collection to generate incremented identifiers.
isIdGeneratorNone ( ) : boolean Checks whether the class uses no id generator.
isIdGeneratorUuid ( ) : boolean Checks whether the class will generate a uuid id.
isIdentifier ( $fieldName ) {@inheritDoc}
isInheritanceTypeCollectionPerClass ( ) : boolean Checks whether the mapped class uses the COLLECTION_PER_CLASS inheritance mapping strategy.
isInheritanceTypeNone ( ) : boolean
isInheritanceTypeSingleCollection ( ) : boolean Checks whether the mapped class uses the SINGLE_COLLECTION inheritance mapping strategy.
isInheritedField ( string $fieldName ) : boolean Checks whether a mapped field is inherited from an entity superclass.
isMappedToCollection ( ) : boolean Returns TRUE if this Document is mapped to a collection FALSE otherwise.
isNullable ( string $fieldName ) : boolean Check if the field is not null.
isSharded ( ) : boolean Checks whether this document has shard key or not.
isSingleValuedAssociation ( $fieldName ) {@inheritDoc}
isSingleValuedEmbed ( string $fieldName ) : boolean Checks whether the class has a mapped embedded document for the specified field and if yes, checks whether it is a single-valued association (to-one).
isSingleValuedReference ( string $fieldName ) : boolean Checks whether the class has a mapped association for the specified field and if yes, checks whether it is a single-valued association (to-one).
mapField ( array $mapping ) : array Map a field.
mapFile ( array $mapping ) Map a MongoGridFSFile.
mapManyEmbedded ( array $mapping ) Map a collection of embedded documents.
mapManyReference ( array $mapping ) Map a collection of document references.
mapOneEmbedded ( array $mapping ) Map a single embedded document.
mapOneReference ( array $mapping ) Map a single document reference.
registerAlsoLoadMethod ( string $method, array | string $fields ) Registers a method for loading document data before field hydration.
setAlsoLoadMethods ( array $methods ) Sets the AlsoLoad methods for documents of this class.
setChangeTrackingPolicy ( integer $policy ) Sets the change tracking policy used by this class.
setCollection ( array | string $name ) Sets the collection this Document is mapped to.
setCollectionCapped ( boolean $bool ) Set whether or not the documents collection is capped.
setCollectionMax ( integer $max ) Set the collection max.
setCollectionSize ( integer $size ) Set the collection size.
setCustomRepositoryClass ( string $repositoryClassName ) Registers a custom repository class for the document class.
setDatabase ( string $db ) Set the database this Document is mapped to.
setDefaultDiscriminatorValue ( string $defaultDiscriminatorValue ) Sets the default discriminator value to be used for this class Used for JOINED and SINGLE_TABLE inheritance mapping strategies if the document has no discriminator value
setDiscriminatorField ( string $discriminatorField ) Sets the discriminator field.
setDiscriminatorMap ( array $map ) Sets the discriminator values used by this class.
setDiscriminatorValue ( string $value ) Sets the discriminator value for this class.
setDistance ( string $distance ) Set the field name that stores the distance.
setFieldValue ( object $document, string $field, mixed $value ) Sets the specified field to the specified value on the given document.
setFile ( string $file ) Set the field name that stores the grid file.
setIdGenerator ( AbstractIdGenerator $generator ) Sets the ID generator used to generate IDs for instances of this class.
setIdGeneratorOptions ( array $generatorOptions ) Sets the Id generator options.
setIdGeneratorType ( string $generatorType ) Sets the type of Id generator to use for the mapped class.
setIdentifier ( string $identifier ) INTERNAL: Sets the mapped identifier field of this class.
setIdentifierValue ( object $document, mixed $id ) Sets the document identifier of a document.
setInheritanceType ( integer $type ) Sets the inheritance type used by the class and it's subclasses.
setLifecycleCallbacks ( array $callbacks ) Sets the lifecycle callbacks for documents of this class.
setLockField ( string $lockField ) Sets the name of the field that is to be used for storing whether a document is currently locked or not.
setLockMapping ( array &$mapping ) Sets the version field mapping used for versioning. Sets the default value to use depending on the column type.
setLockable ( boolean $bool ) Sets whether this class is to allow pessimistic locking.
setParentClasses ( array $classNames ) Sets the parent class names.
setRequireIndexes ( boolean $requireIndexes ) Set whether or not queries on this document should require indexes.
setShardKey ( array $keys, array $options = [] ) Set shard key for this Document.
setSlaveOkay ( boolean | null $slaveOkay ) Sets the slaveOkay option applied to collections for this class.
setSubclasses ( array $subclasses ) Sets the mapped subclasses of this class.
setVersionField ( string $versionField ) Sets the name of the field that is to be used for versioning if this class is versioned for optimistic locking.
setVersionMapping ( array &$mapping ) Sets the version field mapping used for versioning. Sets the default value to use depending on the column type.
setVersioned ( boolean $bool ) Sets whether this class is to be versioned for optimistic locking.
setWriteConcern ( string $writeConcern ) Sets the write concern used by this class.

Private Methods

Method Description
applyStorageStrategy ( array &$mapping ) Validates the storage strategy of a mapping for consistency

Method Details

__construct() public method

Initializes a new ClassMetadata instance that will hold the object-document mapping metadata of the class with the given name.
public __construct ( string $documentName )
$documentName string The name of the document class the new instance is used for.

addIndex() public method

Add a index for this Document.
public addIndex ( array $keys, array $options = [] )
$keys array Array of keys for the index.
$options array Array of options for the index.

addInheritedAssociationMapping() public method

This is mainly used to add inherited association mappings to derived classes.
public addInheritedAssociationMapping ( array $mapping ) : void
$mapping array
return void

addInheritedFieldMapping() public method

This is mainly used to add inherited field mappings to derived classes.
public addInheritedFieldMapping ( array $fieldMapping )
$fieldMapping array

addLifecycleCallback() public method

If the callback is already registered, this is a NOOP.
public addLifecycleCallback ( string $callback, string $event )
$callback string
$event string

getAssociationCollectionClass() public method

Retrieve the collectionClass associated with an association
public getAssociationCollectionClass ( string $assocName )
$assocName string

getAssociationMappedByTargetField() public method

{@inheritDoc}
public getAssociationMappedByTargetField ( $fieldName )

getAssociationNames() public method

{@inheritDoc}
public getAssociationNames ( )

getAssociationTargetClass() public method

{@inheritDoc}
public getAssociationTargetClass ( $assocName )

getCollection() public method

Get the collection this Document is mapped to.
public getCollection ( ) : string
return string $collection The collection name.

getCollectionCapped() public method

Get whether or not the documents collection is capped.
public getCollectionCapped ( ) : boolean
return boolean

getCollectionMax() public method

Get the collection max.
public getCollectionMax ( ) : integer
return integer

getCollectionSize() public method

Get the collection size
public getCollectionSize ( ) : integer
return integer

getDatabase() public method

Returns the database this Document is mapped to.
public getDatabase ( ) : string
return string $db The database name.

getDatabaseIdentifierValue() public method

Casts the identifier to its database type.
public getDatabaseIdentifierValue ( mixed $id ) : mixed
$id mixed
return mixed $id

getDistance() public method

Returns the distance field name.
public getDistance ( ) : string
return string $distance The distance field name.

getEmbeddedFieldsMappings() public method

Gets mappings of fields holding embedded document(s).
public getEmbeddedFieldsMappings ( ) : array
return array of field mappings

getFieldMapping() public method

Gets the mapping of a field.
public getFieldMapping ( string $fieldName ) : array
$fieldName string The field name.
return array The field mapping.

getFieldMappingByDbFieldName() public method

E.g. it returns identifier's mapping when called with _id.
public getFieldMappingByDbFieldName ( string $dbFieldName ) : array
$dbFieldName string
return array

getFieldNames() public method

{@inheritDoc}
public getFieldNames ( )

getFieldValue() public method

Gets the specified field's value off the given document.
public getFieldValue ( object $document, string $field ) : mixed
$document object
$field string
return mixed

getFile() public method

Returns the file field name.
public getFile ( ) : string
return string $file The file field name.

getIdentifier() public method

Since MongoDB only allows exactly one identifier field this will always return an array with only one value
public getIdentifier ( )

getIdentifierFieldNames() public method

Since MongoDB only allows exactly one identifier field this will always return an array with only one value

getIdentifierObject() public method

Get the document identifier object as a database type.
public getIdentifierObject ( object $document ) : MongoId
$document object
return MongoId $id The MongoID object.

getIdentifierValue() public method

Gets the document identifier as a PHP type.
public getIdentifierValue ( object $document ) : mixed
$document object
return mixed $id

getIdentifierValues() public method

Since MongoDB only allows exactly one identifier field this is a proxy to {@see \getIdentifierValue()} and returns an array with the identifier field as a key.
public getIdentifierValues ( $object )

getIndexes() public method

Returns the array of indexes for this Document.
public getIndexes ( ) : array
return array $indexes The array of indexes.

getLifecycleCallbacks() public method

Gets the registered lifecycle callbacks for an event.
public getLifecycleCallbacks ( string $event ) : array
$event string
return array

getName() public method

{@inheritDoc}
public getName ( )

getNamespace() public method

The namespace this Document class belongs to.
public getNamespace ( ) : string
return string $namespace The namespace name.

getPHPIdentifierValue() public method

Casts the identifier to its portable PHP type.
public getPHPIdentifierValue ( mixed $id ) : mixed
$id mixed
return mixed $id

getReflectionClass() public method

{@inheritDoc}
public getReflectionClass ( )

getReflectionProperties() public method

Gets the ReflectionProperties of the mapped class.
public getReflectionProperties ( ) : array
return array An array of ReflectionProperty instances.

getReflectionProperty() public method

Gets a ReflectionProperty for a specific field of the mapped class.
public getReflectionProperty ( string $name ) : ReflectionProperty
$name string
return ReflectionProperty

getShardKey() public method

public getShardKey ( ) : array
return array

getTypeOfField() public method

{@inheritDoc}
public getTypeOfField ( $fieldName )

getWriteConcern() public method

public getWriteConcern ( ) : string
return string

hasAssociation() public method

Checks whether the class has a mapped association (embed or reference) with the given field name.
public hasAssociation ( $fieldName )

hasDiscriminator() public method

Checks whether the document has a discriminator field and value configured.
public hasDiscriminator ( ) : boolean
return boolean

hasEmbed() public method

Checks whether the class has a mapped embed with the given field name.
public hasEmbed ( string $fieldName ) : boolean
$fieldName string
return boolean

hasField() public method

{@inheritDoc}
public hasField ( $fieldName )

hasIndexes() public method

Checks whether this document has indexes or not.
public hasIndexes ( ) : boolean
return boolean

hasLifecycleCallbacks() public method

Checks whether the class has callbacks registered for a lifecycle event.
public hasLifecycleCallbacks ( string $event ) : boolean
$event string Lifecycle event
return boolean

hasReference() public method

Checks whether the class has a mapped association with the given field name.
public hasReference ( string $fieldName ) : boolean
$fieldName string
return boolean

hasWriteConcern() public method

Whether there is a write concern configured for this class.
public hasWriteConcern ( ) : boolean
return boolean

invokeLifecycleCallbacks() public method

Dispatches the lifecycle event of the given document by invoking all registered callbacks.
public invokeLifecycleCallbacks ( string $event, object $document, array $arguments = null )
$event string Lifecycle event
$document object Document on which the event occurred
$arguments array Arguments to pass to all callbacks

isAssociationInverseSide() public method

{@inheritDoc}
public isAssociationInverseSide ( $fieldName )

isChangeTrackingDeferredExplicit() public method

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

isChangeTrackingDeferredImplicit() public method

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

isChangeTrackingNotify() public method

Whether the change tracking policy of this class is "notify".
public isChangeTrackingNotify ( ) : boolean
return boolean

isCollectionValuedAssociation() public method

Checks whether the class has a mapped reference or embed for the specified field and is a collection valued association.
public isCollectionValuedAssociation ( $fieldName )

isCollectionValuedEmbed() public method

Checks whether the class has a mapped embedded document for the specified field and if yes, checks whether it is a collection-valued association (to-many).
public isCollectionValuedEmbed ( string $fieldName ) : boolean
$fieldName string
return boolean TRUE if the association exists and is collection-valued, FALSE otherwise.

isCollectionValuedReference() public method

Checks whether the class has a mapped association for the specified field and if yes, checks whether it is a collection-valued association (to-many).
public isCollectionValuedReference ( string $fieldName ) : boolean
$fieldName string
return boolean TRUE if the association exists and is collection-valued, FALSE otherwise.

isFile() public method

Returns TRUE if this Document is a file to be stored on the MongoGridFS FALSE otherwise.
public isFile ( ) : boolean
return boolean

isIdGeneratorAuto() public method

Checks whether the class will generate a new \MongoId instance for us.
public isIdGeneratorAuto ( ) : boolean
return boolean TRUE if the class uses the AUTO generator, FALSE otherwise.

isIdGeneratorIncrement() public method

Checks whether the class will use a collection to generate incremented identifiers.
public isIdGeneratorIncrement ( ) : boolean
return boolean TRUE if the class uses the INCREMENT generator, FALSE otherwise.

isIdGeneratorNone() public method

Checks whether the class uses no id generator.
public isIdGeneratorNone ( ) : boolean
return boolean TRUE if the class does not use any id generator, FALSE otherwise.

isIdGeneratorUuid() public method

Checks whether the class will generate a uuid id.
public isIdGeneratorUuid ( ) : boolean
return boolean TRUE if the class uses the UUID generator, FALSE otherwise.

isIdentifier() public method

{@inheritDoc}
public isIdentifier ( $fieldName )

isInheritanceTypeCollectionPerClass() public method

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

isInheritanceTypeNone() public method

public isInheritanceTypeNone ( ) : boolean
return boolean

isInheritanceTypeSingleCollection() public method

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

isInheritedField() public method

Checks whether a mapped field is inherited from an entity superclass.
public isInheritedField ( string $fieldName ) : boolean
$fieldName string
return boolean TRUE if the field is inherited, FALSE otherwise.

isMappedToCollection() public method

Returns TRUE if this Document is mapped to a collection FALSE otherwise.
public isMappedToCollection ( ) : boolean
return boolean

isNullable() public method

Check if the field is not null.
public isNullable ( string $fieldName ) : boolean
$fieldName string The field name
return boolean TRUE if the field is not null, FALSE otherwise.

isSharded() public method

Checks whether this document has shard key or not.
public isSharded ( ) : boolean
return boolean

isSingleValuedAssociation() public method

Checks whether the class has a mapped reference or embed for the specified field and is a single valued association.
public isSingleValuedAssociation ( $fieldName )

isSingleValuedEmbed() public method

Checks whether the class has a mapped embedded document for the specified field and if yes, checks whether it is a single-valued association (to-one).
public isSingleValuedEmbed ( string $fieldName ) : boolean
$fieldName string
return boolean TRUE if the association exists and is single-valued, FALSE otherwise.

isSingleValuedReference() public method

Checks whether the class has a mapped association for the specified field and if yes, checks whether it is a single-valued association (to-one).
public isSingleValuedReference ( string $fieldName ) : boolean
$fieldName string
return boolean TRUE if the association exists and is single-valued, FALSE otherwise.

mapField() public method

Map a field.
public mapField ( array $mapping ) : array
$mapping array The mapping information.
return array

mapFile() public method

Map a MongoGridFSFile.
public mapFile ( array $mapping )
$mapping array The mapping information.

mapManyEmbedded() public method

Map a collection of embedded documents.
public mapManyEmbedded ( array $mapping )
$mapping array The mapping information.

mapManyReference() public method

Map a collection of document references.
public mapManyReference ( array $mapping )
$mapping array The mapping information.

mapOneEmbedded() public method

Map a single embedded document.
public mapOneEmbedded ( array $mapping )
$mapping array The mapping information.

mapOneReference() public method

Map a single document reference.
public mapOneReference ( array $mapping )
$mapping array The mapping information.

registerAlsoLoadMethod() public method

Note: A method may be registered multiple times for different fields. it will be invoked only once for the first field found.
public registerAlsoLoadMethod ( string $method, array | string $fields )
$method string Method name
$fields array | string Database field name(s)

setAlsoLoadMethods() public method

Any previously registered methods are overwritten.
public setAlsoLoadMethods ( array $methods )
$methods array

setChangeTrackingPolicy() public method

Sets the change tracking policy used by this class.
public setChangeTrackingPolicy ( integer $policy )
$policy integer

setCollection() public method

Sets the collection this Document is mapped to.
public setCollection ( array | string $name )
$name array | string

setCollectionCapped() public method

Set whether or not the documents collection is capped.
public setCollectionCapped ( boolean $bool )
$bool boolean

setCollectionMax() public method

Set the collection max.
public setCollectionMax ( integer $max )
$max integer

setCollectionSize() public method

Set the collection size.
public setCollectionSize ( integer $size )
$size integer

setCustomRepositoryClass() public method

Registers a custom repository class for the document class.
public setCustomRepositoryClass ( string $repositoryClassName )
$repositoryClassName string The class name of the custom repository.

setDatabase() public method

Set the database this Document is mapped to.
public setDatabase ( string $db )
$db string The database name

setDefaultDiscriminatorValue() public method

Sets the default discriminator value to be used for this class Used for JOINED and SINGLE_TABLE inheritance mapping strategies if the document has no discriminator value
public setDefaultDiscriminatorValue ( string $defaultDiscriminatorValue )
$defaultDiscriminatorValue string

setDiscriminatorField() public method

The field name is the the unmapped database field. Discriminator values are only used to discern the hydration class and are not mapped to class properties.
public setDiscriminatorField ( string $discriminatorField )
$discriminatorField string

setDiscriminatorMap() public method

Used for JOINED and SINGLE_TABLE inheritance mapping strategies.
public setDiscriminatorMap ( array $map )
$map array

setDiscriminatorValue() public method

Used for JOINED/SINGLE_TABLE inheritance and multiple document types in a single collection.
public setDiscriminatorValue ( string $value )
$value string

setDistance() public method

Set the field name that stores the distance.
public setDistance ( string $distance )
$distance string

setFieldValue() public method

Sets the specified field to the specified value on the given document.
public setFieldValue ( object $document, string $field, mixed $value )
$document object
$field string
$value mixed

setFile() public method

Set the field name that stores the grid file.
public setFile ( string $file )
$file string

setIdGenerator() public method

Sets the ID generator used to generate IDs for instances of this class.
public setIdGenerator ( AbstractIdGenerator $generator )
$generator Doctrine\ODM\MongoDB\Id\AbstractIdGenerator

setIdGeneratorOptions() public method

Sets the Id generator options.
public setIdGeneratorOptions ( array $generatorOptions )
$generatorOptions array Generator options.

setIdGeneratorType() public method

Sets the type of Id generator to use for the mapped class.
public setIdGeneratorType ( string $generatorType )
$generatorType string Generator type.

setIdentifier() public method

INTERNAL: Sets the mapped identifier field of this class.
public setIdentifier ( string $identifier )
$identifier string

setIdentifierValue() public method

The value will be converted to a PHP type before being set.
public setIdentifierValue ( object $document, mixed $id )
$document object
$id mixed

setInheritanceType() public method

Sets the inheritance type used by the class and it's subclasses.
public setInheritanceType ( integer $type )
$type integer

setLifecycleCallbacks() public method

Any previously registered callbacks are overwritten.
public setLifecycleCallbacks ( array $callbacks )
$callbacks array

setLockField() public method

Sets the name of the field that is to be used for storing whether a document is currently locked or not.
public setLockField ( string $lockField )
$lockField string

setLockMapping() public method

Sets the version field mapping used for versioning. Sets the default value to use depending on the column type.
public setLockMapping ( array &$mapping )
$mapping array The version field mapping array

setLockable() public method

Sets whether this class is to allow pessimistic locking.
public setLockable ( boolean $bool )
$bool boolean

setParentClasses() public method

Assumes that the class names in the passed array are in the order: directParent -> directParentParent -> directParentParentParent ... -> root.
public setParentClasses ( array $classNames )
$classNames array

setRequireIndexes() public method

Set whether or not queries on this document should require indexes.
Deprecation: method was deprecated in 1.2 and will be removed in 2.0
public setRequireIndexes ( boolean $requireIndexes )
$requireIndexes boolean

setShardKey() public method

Set shard key for this Document.
public setShardKey ( array $keys, array $options = [] )
$keys array Array of document keys.
$options array Array of sharding options.

setSlaveOkay() public method

Sets the slaveOkay option applied to collections for this class.
public setSlaveOkay ( boolean | null $slaveOkay )
$slaveOkay boolean | null

setSubclasses() public method

Sets the mapped subclasses of this class.
public setSubclasses ( array $subclasses )
$subclasses array The names of all mapped subclasses.

setVersionField() public method

Sets the name of the field that is to be used for versioning if this class is versioned for optimistic locking.
public setVersionField ( string $versionField )
$versionField string

setVersionMapping() public method

Sets the version field mapping used for versioning. Sets the default value to use depending on the column type.
public setVersionMapping ( array &$mapping )
$mapping array The version field mapping array

setVersioned() public method

Sets whether this class is to be versioned for optimistic locking.
public setVersioned ( boolean $bool )
$bool boolean

setWriteConcern() public method

Sets the write concern used by this class.
public setWriteConcern ( string $writeConcern )
$writeConcern string

Property Details

$alsoLoadMethods public property

READ-ONLY: Array of fields to also load with a given method.
public array $alsoLoadMethods
return array

$associationMappings public property

Keys are field names and values are mapping definitions.
public array $associationMappings
return array

$changeTrackingPolicy public property

READ-ONLY: The policy used for change-tracking on entities of this class.
public int $changeTrackingPolicy
return integer

$collection public property

READ-ONLY: The name of the mongo collection the document is mapped to.
public $collection

$collectionCapped public property

READ-ONLY: If the collection should be a fixed size.
public $collectionCapped

$collectionMax public property

READ-ONLY: If the collection is fixed size, the maximum number of elements to store in the collection.
public $collectionMax

$collectionSize public property

READ-ONLY: If the collection is fixed size, its size in bytes.
public $collectionSize

$customRepositoryClassName public property

(Optional).
public string $customRepositoryClassName
return string

$db public property

READ-ONLY: The name of the mongo database the document is mapped to.
public $db

$defaultDiscriminatorValue public property

READ-ONLY: The default value for discriminatorField in case it's not set in the document
See also: discriminatorField
public string $defaultDiscriminatorValue
return string

$discriminatorField public property

READ-ONLY: The definition of the discriminator field used in SINGLE_COLLECTION inheritance mapping.
public string $discriminatorField
return string

$discriminatorMap public property

This does only apply to the SINGLE_COLLECTION inheritance mapping strategy where a discriminator field is used.
See also: discriminatorField
public mixed $discriminatorMap
return mixed

$discriminatorValue public property

This does only apply to the JOINED and SINGLE_COLLECTION inheritance mapping strategies where a discriminator field is used.
See also: discriminatorField
public mixed $discriminatorValue
return mixed

$distance public property

READ-ONLY: The field that stores the calculated distance when performing geo spatial queries.
public $distance

$fieldMappings public property

Keys are field names and values are mapping definitions. The mapping definition array has the following values: - fieldName (string) The name of the field in the Document. - id (boolean, optional) Marks the field as the primary key of the document. Multiple fields of an document can have the id attribute, forming a composite key.
public array $fieldMappings
return array

$file public property

READ-ONLY: The field that stores a file reference and indicates the document is a file and should be stored on the MongoGridFS.
public $file

$generatorOptions public property

READ-ONLY: The Id generator options.
public array $generatorOptions
return array

$generatorType public property

READ-ONLY: The Id generator type used by the class.
public string $generatorType
return string

$idGenerator public property

READ-ONLY: The ID generator used for generating IDs for this class.
public AbstractIdGenerator,Doctrine\ODM\MongoDB\Id $idGenerator
return Doctrine\ODM\MongoDB\Id\AbstractIdGenerator

$identifier public property

READ-ONLY: The field name of the document identifier.
public $identifier

$indexes public property

READ-ONLY: The array of indexes for the document collection.
public $indexes

$inheritanceType public property

READ-ONLY: The inheritance mapping type used by the class.
public int $inheritanceType
return integer

$isEmbeddedDocument public property

READ-ONLY: Whether this class describes the mapping of a embedded document.
public bool $isEmbeddedDocument
return boolean

$isLockable public property

READ-ONLY: A flag for whether or not instances of this class are to allow pessimistic locking.
public bool $isLockable
return boolean

$isMappedSuperclass public property

READ-ONLY: Whether this class describes the mapping of a mapped superclass.
public bool $isMappedSuperclass
return boolean

$isQueryResultDocument public property

READ-ONLY: Whether this class describes the mapping of an aggregation result document.
public bool $isQueryResultDocument
return boolean

$isVersioned public property

READ-ONLY: A flag for whether or not instances of this class are to be versioned with optimistic locking.
public bool $isVersioned
return boolean

$lifecycleCallbacks public property

READ-ONLY: The registered lifecycle callbacks for documents of this class.
public array $lifecycleCallbacks
return array

$lockField public property

READ-ONLY: The name of the field which is used for locking a document.
public mixed $lockField
return mixed

$name public property

READ-ONLY: The name of the document class.
public $name

$namespace public property

READ-ONLY: The namespace the document class is contained in.
public string $namespace
return string

$parentClasses public property

READ-ONLY: The names of the parent classes (ancestors).
public array $parentClasses
return array

$reflClass public property

The ReflectionClass instance of the mapped class.
public ReflectionClass $reflClass
return ReflectionClass

$reflFields public property

The ReflectionProperty instances of the mapped class.
public ReflectionProperty[] $reflFields
return ReflectionProperty[]

$requireIndexes public property

READ-ONLY: Whether or not queries on this document should require indexes.
Deprecation: property was deprecated in 1.2 and will be removed in 2.0
public $requireIndexes

$rootDocumentName public property

READ-ONLY: The name of the document class that is at the root of the mapped document inheritance hierarchy. If the document is not part of a mapped inheritance hierarchy this is the same as {@link $documentName}.
public string $rootDocumentName
return string

$shardKey public property

READ-ONLY: Keys and options describing shard key. Only for sharded collections.
public $shardKey

$slaveOkay public property

READ-ONLY: Whether or not reads for this class are okay to read from a slave.
public $slaveOkay

$subClasses public property

READ-ONLY: The names of all subclasses (descendants).
public array $subClasses
return array

$versionField public property

READ-ONLY: The name of the field which is used for versioning in optimistic locking (if any).
public mixed $versionField
return mixed

$writeConcern public property

READ-ONLY: Describes the level of acknowledgement requested from MongoDB for write operations.
public $writeConcern