class ClassMetadataInfo implements ClassMetadata (View source)

A ClassMetadata instance holds all the object-document mapping metadata of a document and it's references.

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

Constants

GENERATOR_TYPE_AUTO

AUTO means Doctrine will automatically create a new \MongoId instance for us.

GENERATOR_TYPE_INCREMENT

INCREMENT means a separate collection is used for maintaining and incrementing id generation.

Offers full portability.

GENERATOR_TYPE_UUID

UUID means Doctrine will generate a uuid for us.

GENERATOR_TYPE_ALNUM

ALNUM means Doctrine will generate Alpha-numeric string identifiers, using the INCREMENT generator to ensure identifier uniqueness

GENERATOR_TYPE_CUSTOM

CUSTOM means Doctrine expect a class parameter. It will then try to initiate that class and pass other options to the generator. It will throw an Exception if the class does not exist or if an option was passed for that there is not setter in the new generator class.

The class will have to be a subtype of AbstractIdGenerator.

GENERATOR_TYPE_NONE

NONE means Doctrine will not generate any id for us and you are responsible for manually assigning an id.

DEFAULT_DISCRIMINATOR_FIELD

Default discriminator field name.

This is used for associations value for associations where a that do not define a "targetDocument" or "discriminatorField" option in their mapping.

REFERENCE_ONE

REFERENCE_MANY

EMBED_ONE

EMBED_MANY

MANY

ONE

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_SINGLE_COLLECTION

SINGLE_COLLECTION means the class will be persisted according to the rules of Single Collection Inheritance.

INHERITANCE_TYPE_COLLECTION_PER_CLASS

COLLECTION_PER_CLASS means the class will be persisted according to the rules of Concrete Collection Inheritance.

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.

Properties

$db READ-ONLY: The name of the mongo database the document is mapped to.
$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.
$collectionSize READ-ONLY: If the collection is fixed size, its size in bytes.
$collectionMax READ-ONLY: If the collection is fixed size, the maximum number of elements to store in the collection.
$identifier READ-ONLY: The field name of the document identifier.
$file READ-ONLY: The field that stores a file reference and indicates the document is a file and should be stored on the MongoGridFS.
$distance READ-ONLY: The field that stores the calculated distance when performing geo spatial queries.
$slaveOkay READ-ONLY: Whether or not reads for this class are okay to read from a slave.
$indexes READ-ONLY: The array of indexes for the document collection.
$requireIndexes READ-ONLY: Whether or not queries on this document should require indexes.
$name READ-ONLY: The name of the document class.
string $namespace READ-ONLY: The namespace the document class is contained in.
string $rootDocumentName 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}.
string $customRepositoryClassName The name of the custom repository class used for the document class.
array $parentClasses READ-ONLY: The names of the parent classes (ancestors).
array $subClasses READ-ONLY: The names of all subclasses (descendants).
ReflectionProperty[] $reflFields The ReflectionProperty instances of the mapped class.
integer $inheritanceType READ-ONLY: The inheritance mapping type used by the class.
string $generatorType READ-ONLY: The Id generator type used by the class.
array $generatorOptions READ-ONLY: The Id generator options.
AbstractIdGenerator $idGenerator READ-ONLY: The ID generator used for generating IDs for this class.
array $fieldMappings READ-ONLY: The field mappings of the class.
array $associationMappings READ-ONLY: The association mappings of the class.
array $alsoLoadMethods READ-ONLY: Array of fields to also load with a given method.
array $lifecycleCallbacks READ-ONLY: The registered lifecycle callbacks for documents of this class.
mixed $discriminatorValue READ-ONLY: The discriminator value of this class.
mixed $discriminatorMap READ-ONLY: The discriminator map of all mapped classes in the hierarchy.
string $discriminatorField READ-ONLY: The definition of the discriminator field used in SINGLE_COLLECTION inheritance mapping.
string $defaultDiscriminatorValue READ-ONLY: The default value for discriminatorField in case it's not set in the document
boolean $isMappedSuperclass READ-ONLY: Whether this class describes the mapping of a mapped superclass.
boolean $isEmbeddedDocument READ-ONLY: Whether this class describes the mapping of a embedded document.
integer $changeTrackingPolicy READ-ONLY: The policy used for change-tracking on entities of this class.
boolean $isVersioned READ-ONLY: A flag for whether or not instances of this class are to be versioned with optimistic locking.
mixed $versionField READ-ONLY: The name of the field which is used for versioning in optimistic locking (if any).
boolean $isLockable READ-ONLY: A flag for whether or not instances of this class are to allow pessimistic locking.
mixed $lockField READ-ONLY: The name of the field which is used for locking a document.
ReflectionClass $reflClass The ReflectionClass instance of the mapped class.

Methods

__construct(string $documentName)

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

getReflectionClass()

{@inheritDoc}

isIdentifier($fieldName)

{@inheritDoc}

setIdentifier(string $identifier)

INTERNAL: Sets the mapped identifier field of this class.

getIdentifier()

{@inheritDoc}

getIdentifierFieldNames()

{@inheritDoc}

hasField($fieldName)

{@inheritDoc}

setInheritanceType(integer $type)

Sets the inheritance type used by the class and it's subclasses.

boolean
isInheritedField(string $fieldName)

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

setCustomRepositoryClass(string $repositoryClassName)

Registers a custom repository class for the document class.

invokeLifecycleCallbacks(string $event, object $document, array $arguments = null)

Dispatches the lifecycle event of the given document by invoking all registered callbacks.

boolean
hasLifecycleCallbacks(string $event)

Checks whether the class has callbacks registered for a lifecycle event.

array
getLifecycleCallbacks(string $event)

Gets the registered lifecycle callbacks for an event.

addLifecycleCallback(string $callback, string $event)

Adds a lifecycle callback for documents of this class.

setLifecycleCallbacks(array $callbacks)

Sets the lifecycle callbacks for documents of this class.

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.

setDiscriminatorField(string $discriminatorField)

Sets the discriminator field.

setDiscriminatorMap(array $map)

Sets the discriminator values used by this class.

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

setDiscriminatorValue(string $value)

Sets the discriminator value for this class.

setSlaveOkay(boolean|null $slaveOkay)

Sets the slaveOkay option applied to collections for this class.

addIndex(array $keys, array $options = array())

Add a index for this Document.

setRequireIndexes(bool $requireIndexes)

Set whether or not queries on this document should require indexes.

array
getIndexes()

Returns the array of indexes for this Document.

boolean
hasIndexes()

Checks whether this document has indexes or not.

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

array
getReflectionProperties()

Gets the ReflectionProperties of the mapped class.

getReflectionProperty(string $name)

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

getName()

{@inheritDoc}

string
getNamespace()

The namespace this Document class belongs to.

string
getDatabase()

Returns the database this Document is mapped to.

setDatabase(string $db)

Set the database this Document is mapped to.

string
getCollection()

Get the collection this Document is mapped to.

setCollection(array|string $name)

Sets the collection this Document is mapped to.

boolean
getCollectionCapped()

Get whether or not the documents collection is capped.

setCollectionCapped(boolean $bool)

Set whether or not the documents collection is capped.

integer
getCollectionSize()

Get the collection size

setCollectionSize(integer $size)

Set the collection size.

integer
getCollectionMax()

Get the collection max.

setCollectionMax(integer $max)

Set the collection max.

boolean
isMappedToCollection()

Returns TRUE if this Document is mapped to a collection FALSE otherwise.

boolean
isFile()

Returns TRUE if this Document is a file to be stored on the MongoGridFS FALSE otherwise.

string
getFile()

Returns the file field name.

setFile(string $file)

Set the field name that stores the grid file.

string
getDistance()

Returns the distance field name.

setDistance(string $distance)

Set the field name that stores the distance.

array
mapField(array $mapping)

Map a field.

mapFile(array $mapping)

Map a MongoGridFSFile.

mapOneEmbedded(array $mapping)

Map a single embedded document.

mapManyEmbedded(array $mapping)

Map a collection of embedded documents.

mapOneReference(array $mapping)

Map a single document reference.

mapManyReference(array $mapping)

Map a collection of document references.

addInheritedFieldMapping(array $fieldMapping)

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

void
addInheritedAssociationMapping(array $mapping)

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

boolean
hasReference(string $fieldName)

Checks whether the class has a mapped association with the given field name.

boolean
hasEmbed(string $fieldName)

Checks whether the class has a mapped embed with the given field name.

hasAssociation($fieldName)

{@inheritDoc}

isSingleValuedAssociation($fieldName)

{@inheritDoc}

isCollectionValuedAssociation($fieldName)

{@inheritDoc}

boolean
isSingleValuedReference(string $fieldName)

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

boolean
isCollectionValuedReference(string $fieldName)

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

boolean
isSingleValuedEmbed(string $fieldName)

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

boolean
isCollectionValuedEmbed(string $fieldName)

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

setIdGenerator(AbstractIdGenerator $generator)

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

mixed
getPHPIdentifierValue(mixed $id)

Casts the identifier to its portable PHP type.

mixed
getDatabaseIdentifierValue(mixed $id)

Casts the identifier to its database type.

setIdentifierValue(object $document, mixed $id)

Sets the document identifier of a document.

mixed
getIdentifierValue(object $document)

Gets the document identifier as a PHP type.

getIdentifierValues($object)

{@inheritDoc}

MongoId
getIdentifierObject(object $document)

Get the document identifier object as a database type.

setFieldValue(object $document, string $field, mixed $value)

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

mixed
getFieldValue(object $document, string $field)

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

array
getFieldMapping(string $fieldName)

Gets the mapping of a field.

boolean
isNullable(string $fieldName)

Check if the field is not null.

boolean
hasDiscriminator()

Checks whether the document has a discriminator field and value configured.

setIdGeneratorType($generatorType)

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

setIdGeneratorOptions($generatorOptions)

Sets the Id generator options.

boolean
isInheritanceTypeNone()

No description

boolean
isInheritanceTypeSingleCollection()

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

boolean
isInheritanceTypeCollectionPerClass()

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

setSubclasses(array $subclasses)

Sets the mapped subclasses of this class.

setParentClasses(array $classNames)

Sets the parent class names.

boolean
isIdGeneratorAuto()

Checks whether the class will generate a new \MongoId instance for us.

boolean
isIdGeneratorIncrement()

Checks whether the class will use a collection to generate incremented identifiers.

boolean
isIdGeneratorUuid()

Checks whether the class will generate a uuid id.

boolean
isIdGeneratorNone()

Checks whether the class uses no id generator.

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.

setVersionField(string $versionField)

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

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.

setLockField(string $lockField)

Sets the name of the field that is to be used for storing whether a document is currently locked or not.

getFieldNames()

{@inheritDoc}

getAssociationNames()

{@inheritDoc}

getTypeOfField($fieldName)

{@inheritDoc}

getAssociationTargetClass($assocName)

{@inheritDoc}

isAssociationInverseSide($fieldName)

{@inheritDoc}

getAssociationMappedByTargetField($fieldName)

{@inheritDoc}

Details

__construct(string $documentName)

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

Parameters

string $documentName The name of the document class the new instance is used for.

getReflectionClass()

{@inheritDoc}

isIdentifier($fieldName)

{@inheritDoc}

Parameters

$fieldName

setIdentifier(string $identifier)

INTERNAL: Sets the mapped identifier field of this class.

Parameters

string $identifier

getIdentifier()

{@inheritDoc}

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

getIdentifierFieldNames()

{@inheritDoc}

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

hasField($fieldName)

{@inheritDoc}

Parameters

$fieldName

setInheritanceType(integer $type)

Sets the inheritance type used by the class and it's subclasses.

Parameters

integer $type

boolean isInheritedField(string $fieldName)

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

Parameters

string $fieldName

Return Value

boolean TRUE if the field is inherited, FALSE otherwise.

setCustomRepositoryClass(string $repositoryClassName)

Registers a custom repository class for the document class.

Parameters

string $repositoryClassName The class name of the custom repository.

invokeLifecycleCallbacks(string $event, object $document, array $arguments = null)

Dispatches the lifecycle event of the given document by invoking all registered callbacks.

Parameters

string $event Lifecycle event
object $document Document on which the event occurred
array $arguments Arguments to pass to all callbacks

Exceptions

InvalidArgumentException if document class is not this class or a Proxy of this class

boolean hasLifecycleCallbacks(string $event)

Checks whether the class has callbacks registered for a lifecycle event.

Parameters

string $event Lifecycle event

Return Value

boolean

array getLifecycleCallbacks(string $event)

Gets the registered lifecycle callbacks for an event.

Parameters

string $event

Return Value

array

addLifecycleCallback(string $callback, string $event)

Adds a lifecycle callback for documents of this class.

If the callback is already registered, this is a NOOP.

Parameters

string $callback
string $event

setLifecycleCallbacks(array $callbacks)

Sets the lifecycle callbacks for documents of this class.

Any previously registered callbacks are overwritten.

Parameters

array $callbacks

registerAlsoLoadMethod(string $method, array|string $fields)

Registers a method for loading document data before field hydration.

Note: A method may be registered multiple times for different fields. it will be invoked only once for the first field found.

Parameters

string $method Method name
array|string $fields Database field name(s)

setAlsoLoadMethods(array $methods)

Sets the AlsoLoad methods for documents of this class.

Any previously registered methods are overwritten.

Parameters

array $methods

setDiscriminatorField(string $discriminatorField)

Sets the discriminator field.

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.

Parameters

string $discriminatorField

Exceptions

MappingException If the discriminator field conflicts with the "name" attribute of a mapped field.

setDiscriminatorMap(array $map)

Sets the discriminator values used by this class.

Used for JOINED and SINGLE_TABLE inheritance mapping strategies.

Parameters

array $map

Exceptions

MappingException

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

Parameters

string $defaultDiscriminatorValue

Exceptions

MappingException

setDiscriminatorValue(string $value)

Sets the discriminator value for this class.

Used for JOINED/SINGLE_TABLE inheritance and multiple document types in a single collection.

Parameters

string $value

setSlaveOkay(boolean|null $slaveOkay)

Sets the slaveOkay option applied to collections for this class.

Parameters

boolean|null $slaveOkay

addIndex(array $keys, array $options = array())

Add a index for this Document.

Parameters

array $keys Array of keys for the index.
array $options Array of options for the index.

setRequireIndexes(bool $requireIndexes)

Set whether or not queries on this document should require indexes.

Parameters

bool $requireIndexes

array getIndexes()

Returns the array of indexes for this Document.

Return Value

array $indexes The array of indexes.

boolean hasIndexes()

Checks whether this document has indexes or not.

Return Value

boolean

setChangeTrackingPolicy(integer $policy)

Sets the change tracking policy used by this class.

Parameters

integer $policy

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

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

getName()

{@inheritDoc}

string getNamespace()

The namespace this Document class belongs to.

Return Value

string $namespace The namespace name.

string getDatabase()

Returns the database this Document is mapped to.

Return Value

string $db The database name.

setDatabase(string $db)

Set the database this Document is mapped to.

Parameters

string $db The database name

string getCollection()

Get the collection this Document is mapped to.

Return Value

string $collection The collection name.

setCollection(array|string $name)

Sets the collection this Document is mapped to.

Parameters

array|string $name

Exceptions

InvalidArgumentException

boolean getCollectionCapped()

Get whether or not the documents collection is capped.

Return Value

boolean

setCollectionCapped(boolean $bool)

Set whether or not the documents collection is capped.

Parameters

boolean $bool

integer getCollectionSize()

Get the collection size

Return Value

integer

setCollectionSize(integer $size)

Set the collection size.

Parameters

integer $size

integer getCollectionMax()

Get the collection max.

Return Value

integer

setCollectionMax(integer $max)

Set the collection max.

Parameters

integer $max

boolean isMappedToCollection()

Returns TRUE if this Document is mapped to a collection FALSE otherwise.

Return Value

boolean

boolean isFile()

Returns TRUE if this Document is a file to be stored on the MongoGridFS FALSE otherwise.

Return Value

boolean

string getFile()

Returns the file field name.

Return Value

string $file The file field name.

setFile(string $file)

Set the field name that stores the grid file.

Parameters

string $file

string getDistance()

Returns the distance field name.

Return Value

string $distance The distance field name.

setDistance(string $distance)

Set the field name that stores the distance.

Parameters

string $distance

array mapField(array $mapping)

Map a field.

Parameters

array $mapping The mapping information.

Return Value

array

Exceptions

MappingException

mapFile(array $mapping)

Map a MongoGridFSFile.

Parameters

array $mapping The mapping information.

mapOneEmbedded(array $mapping)

Map a single embedded document.

Parameters

array $mapping The mapping information.

mapManyEmbedded(array $mapping)

Map a collection of embedded documents.

Parameters

array $mapping The mapping information.

mapOneReference(array $mapping)

Map a single document reference.

Parameters

array $mapping The mapping information.

mapManyReference(array $mapping)

Map a collection of document references.

Parameters

array $mapping The mapping information.

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

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

boolean hasReference(string $fieldName)

Checks whether the class has a mapped association with the given field name.

Parameters

string $fieldName

Return Value

boolean

boolean hasEmbed(string $fieldName)

Checks whether the class has a mapped embed with the given field name.

Parameters

string $fieldName

Return Value

boolean

hasAssociation($fieldName)

{@inheritDoc}

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

Parameters

$fieldName

isSingleValuedAssociation($fieldName)

{@inheritDoc}

Checks whether the class has a mapped reference or embed for the specified field and is a single valued association.

Parameters

$fieldName

isCollectionValuedAssociation($fieldName)

{@inheritDoc}

Checks whether the class has a mapped reference or embed for the specified field and is a collection valued association.

Parameters

$fieldName

boolean isSingleValuedReference(string $fieldName)

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

Parameters

string $fieldName

Return Value

boolean TRUE if the association exists and is single-valued, FALSE otherwise.

boolean isCollectionValuedReference(string $fieldName)

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

Parameters

string $fieldName

Return Value

boolean TRUE if the association exists and is collection-valued, FALSE otherwise.

boolean isSingleValuedEmbed(string $fieldName)

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

Parameters

string $fieldName

Return Value

boolean TRUE if the association exists and is single-valued, FALSE otherwise.

boolean isCollectionValuedEmbed(string $fieldName)

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

Parameters

string $fieldName

Return Value

boolean TRUE if the association exists and is collection-valued, FALSE otherwise.

setIdGenerator(AbstractIdGenerator $generator)

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

Parameters

AbstractIdGenerator $generator

mixed getPHPIdentifierValue(mixed $id)

Casts the identifier to its portable PHP type.

Parameters

mixed $id

Return Value

mixed $id

mixed getDatabaseIdentifierValue(mixed $id)

Casts the identifier to its database type.

Parameters

mixed $id

Return Value

mixed $id

setIdentifierValue(object $document, mixed $id)

Sets the document identifier of a document.

The value will be converted to a PHP type before being set.

Parameters

object $document
mixed $id

mixed getIdentifierValue(object $document)

Gets the document identifier as a PHP type.

Parameters

object $document

Return Value

mixed $id

getIdentifierValues($object)

{@inheritDoc}

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.

Parameters

$object

MongoId getIdentifierObject(object $document)

Get the document identifier object as a database type.

Parameters

object $document

Return Value

MongoId $id The MongoID object.

setFieldValue(object $document, string $field, mixed $value)

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

Parameters

object $document
string $field
mixed $value

mixed getFieldValue(object $document, string $field)

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

Parameters

object $document
string $field

Return Value

mixed

array getFieldMapping(string $fieldName)

Gets the mapping of a field.

Parameters

string $fieldName The field name.

Return Value

array The field mapping.

Exceptions

MappingException if the $fieldName is not found in the fieldMappings array
MappingException

boolean isNullable(string $fieldName)

Check if the field is not null.

Parameters

string $fieldName The field name

Return Value

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

boolean hasDiscriminator()

Checks whether the document has a discriminator field and value configured.

Return Value

boolean

setIdGeneratorType($generatorType)

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

Parameters

$generatorType

setIdGeneratorOptions($generatorOptions)

Sets the Id generator options.

Parameters

$generatorOptions

boolean isInheritanceTypeNone()

Return Value

boolean

boolean isInheritanceTypeSingleCollection()

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

Return Value

boolean

boolean isInheritanceTypeCollectionPerClass()

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

Return Value

boolean

setSubclasses(array $subclasses)

Sets the mapped subclasses of this class.

Parameters

array $subclasses The names of all mapped subclasses.

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

boolean isIdGeneratorAuto()

Checks whether the class will generate a new \MongoId instance for us.

Return Value

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

boolean isIdGeneratorIncrement()

Checks whether the class will use a collection to generate incremented identifiers.

Return Value

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

boolean isIdGeneratorUuid()

Checks whether the class will generate a uuid id.

Return Value

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

boolean isIdGeneratorNone()

Checks whether the class uses no id generator.

Return Value

boolean TRUE if the class does not use any id generator, FALSE otherwise.

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

Exceptions

LockException

setVersioned(boolean $bool)

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

Parameters

boolean $bool

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

setLockMapping(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

Exceptions

LockException

setLockable(boolean $bool)

Sets whether this class is to allow pessimistic locking.

Parameters

boolean $bool

setLockField(string $lockField)

Sets the name of the field that is to be used for storing whether a document is currently locked or not.

Parameters

string $lockField

getFieldNames()

{@inheritDoc}

getAssociationNames()

{@inheritDoc}

getTypeOfField($fieldName)

{@inheritDoc}

Parameters

$fieldName

getAssociationTargetClass($assocName)

{@inheritDoc}

Parameters

$assocName

isAssociationInverseSide($fieldName)

{@inheritDoc}

Parameters

$fieldName

getAssociationMappedByTargetField($fieldName)

{@inheritDoc}

Parameters

$fieldName