class ClassMetadata implements ClassMetadata (View source)

Metadata class

Constants

IDGENERATOR_UUID

IDGENERATOR_ASSIGNED

TO_ONE

TO_MANY

ONE_TO_ONE

ONE_TO_MANY

MANY_TO_ONE

MANY_TO_MANY

CASCADE_PERSIST

CASCADE_REMOVE

CASCADE_MERGE

CASCADE_DETACH

CASCADE_REFRESH

CASCADE_ALL

Properties

$idGenerator
$identifier READ-ONLY: The field name of the document identifier.
$name READ-ONLY: The name of the document class.
$rootDocumentName READ-ONLY: The root document class name.
$inInheritanceHierachy READ-ONLY: Is this entity in an inheritance hierachy?
$parentClasses READ-ONLY: a list of all parent classes.
string $namespace READ-ONLY: The namespace the document class is contained in.
string $customRepositoryClassName The name of the custom repository class used for the document class.
array $fieldMappings READ-ONLY: The field mappings of the class.
array $indexes An array of indexed fields, accessible through a generic view shipped with Doctrine.
bool $indexed Is this class indexed? If yes, then a findAll() query can be executed for this type.
array $jsonNames An array of json result-key-names to field-names
array $alsoLoadMethods READ-ONLY: Array of fields to also load with a given method.
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.
bool $isReadOnly READ-ONLY: Wheather the document or embedded document is read-only and will be skipped in change-tracking.
array $associationsMappings READ-ONLY
bool $isVersioned CouchDB documents are always versioned, this flag determines if this version is exposed to the userland.
string $versionField Version Field stores the CouchDB Revision
bool $hasAttachments
string $attachmentField Field that stores the attachments as a key->value array of file-names to attachment objects.
string|null $attachmentDeclaredClass If in an inheritance scenario the attachment field is on a super class, this is its name.
ReflectionClass $reflClass The ReflectionClass instance of the mapped class.
array $reflFields The ReflectionProperty instances 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.

deriveChildMetadata(ClassMetadata $child)

Used to derive a class metadata of the current instance for a mapped child class.

array
__sleep()

Determines which fields get serialized.

wakeupReflection($reflService)

Restores some state that can not be serialized/unserialized.

object
newInstance()

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

getReflectionClass()

Gets the ReflectionClass instance of the mapped class.

array
getReflectionProperties()

Gets the ReflectionPropertys of the mapped class.

getReflectionProperty(string $name)

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

setIdentifierValue(object $document, mixed $id)

Sets the document identifier of a document.

string
getIdentifierValue(object $document)

Gets the document identifier.

array
getIdentifierValues(object $document)

Get identifier values of this document.

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

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

getFieldValue(object $document, string $field)

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

boolean
isIdentifier(string $fieldName)

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

setIdentifier(string $identifier)

INTERNAL: Sets the mapped identifier field of this class.

string
getIdentifier()

Gets the mapped identifier field of this class.

array
getIdentifierFieldNames()

Get identifier field names of this class.;

boolean
hasField($fieldName)

Checks whether the class has a (mapped) field with a certain name.

setCustomRepositoryClass(string $repositoryClassName)

Registers a custom repository class for the document class.

string
getName()

The name of this Document class.

string
getNamespace()

The namespace this Document class belongs to.

mapAttachments(string $fieldName)

Set the field that will contain attachments of this document.

mapEmbedded(array $mapping)

Map an embedded object

mapField(array $mapping)

Map a field.

validateAndCompleteFieldMapping($mapping)

No description

validateAndCompleteReferenceMapping($mapping)

No description

validateAndCompleteAssociationMapping($mapping)

No description

mapManyToOne($mapping)

No description

mapManyToMany($mapping)

No description

array
getFieldNames()

A numerically indexed list of field names of this persistent class.

array
getFieldMapping(string $fieldName)

Gets the mapping of a field.

Type
getTypeOfField(string $fieldName)

Gets the type of a field.

boolean
hasAssociation(string $fieldName)

Checks if the given field is a mapped association for this class.

isCollectionValuedAssociation($name)

No description

boolean
isSingleValuedAssociation(string $fieldName)

Checks if the given field is a mapped single valued association for this class.

array
getAssociationNames()

A numerically indexed list of association names of this persistent class.

string
getAssociationTargetClass(string $assocName)

Returns the target class name of the given association.

getAssociationMappedByTargetField($assocName)

{@inheritDoc}

isAssociationInverseSide($assocName)

{@inheritDoc}

isInheritedField($field)

No description

isInheritedAssociation($field)

No description

setParentClasses($classes)

No description

markInheritanceRoot()

No description

void
initializeReflection(ReflectionService $reflService)

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

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.

deriveChildMetadata(ClassMetadata $child)

Used to derive a class metadata of the current instance for a mapped child class.

Parameters

ClassMetadata $child

Exceptions

InvalidArgumentException

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.

wakeupReflection($reflService)

Restores some state that can not be serialized/unserialized.

Parameters

$reflService

object newInstance()

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

Return Value

object

ReflectionClass getReflectionClass()

Gets the ReflectionClass instance of the mapped class.

Return Value

ReflectionClass

array getReflectionProperties()

Gets the ReflectionPropertys 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

setIdentifierValue(object $document, mixed $id)

Sets the document identifier of a document.

Parameters

object $document
mixed $id

string getIdentifierValue(object $document)

Gets the document identifier.

Parameters

object $document

Return Value

string $id

array getIdentifierValues(object $document)

Get identifier values of this document.

Since CouchDB 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 $document

Return Value

array

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

getFieldValue(object $document, string $field)

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

Parameters

object $document
string $field

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.

setIdentifier(string $identifier)

INTERNAL: Sets the mapped identifier field of this class.

Parameters

string $identifier

Exceptions

MappingException

string getIdentifier()

Gets the mapped identifier field of this class.

Return Value

string $identifier

array getIdentifierFieldNames()

Get identifier field names of this class.;

Since CouchDB only allows exactly one identifier field this is a proxy to {see getIdentifier()} and returns an array.

Return Value

array

boolean hasField($fieldName)

Checks whether the class has a (mapped) field with a certain name.

Parameters

$fieldName

Return Value

boolean

setCustomRepositoryClass(string $repositoryClassName)

Registers a custom repository class for the document class.

Parameters

string $repositoryClassName The class name of the custom mapper.

string getName()

The name of this Document class.

Return Value

string $name The Document class name.

string getNamespace()

The namespace this Document class belongs to.

Return Value

string $namespace The namespace name.

mapAttachments(string $fieldName)

Set the field that will contain attachments of this document.

Parameters

string $fieldName

Exceptions

MappingException

mapEmbedded(array $mapping)

Map an embedded object

  • fieldName - The name of the property/field on the mapped php class
  • jsonName - JSON key name of this field in CouchDB.
  • targetDocument - Name of the target document
  • embedded - one or many embedded objects?

Parameters

array $mapping

mapField(array $mapping)

Map a field.

  • type - The Doctrine Type of this field.
  • fieldName - The name of the property/field on the mapped php class
  • jsonName - JSON key name of this field in CouchDB.
  • name - The JSON key of this field in the CouchDB document
  • id - True for an ID field.
  • strategy - ID Generator strategy when the field is an id-field.
  • indexed - Is this field indexed for the Doctrine CouchDB repository view
  • isVersionField - Is this field containing the revision number of this document?

Parameters

array $mapping The mapping information.

protected validateAndCompleteFieldMapping($mapping)

Parameters

$mapping

protected validateAndCompleteReferenceMapping($mapping)

Parameters

$mapping

protected validateAndCompleteAssociationMapping($mapping)

Parameters

$mapping

mapManyToOne($mapping)

Parameters

$mapping

mapManyToMany($mapping)

Parameters

$mapping

array getFieldNames()

A numerically indexed list of field names of this persistent class.

This array includes identifier fields if present on this class.

Return Value

array

array getFieldMapping(string $fieldName)

Gets the mapping of a field.

Parameters

string $fieldName The field name.

Return Value

array The field mapping.

Exceptions

MappingException

Type getTypeOfField(string $fieldName)

Gets the type of a field.

Parameters

string $fieldName

Return Value

Type

boolean hasAssociation(string $fieldName)

Checks if the given field is a mapped association for this class.

Parameters

string $fieldName

Return Value

boolean

isCollectionValuedAssociation($name)

Parameters

$name

boolean isSingleValuedAssociation(string $fieldName)

Checks if the given field is a mapped single valued association for this class.

Parameters

string $fieldName

Return Value

boolean

array getAssociationNames()

A numerically indexed list of association names of this persistent class.

This array includes identifier associations if present on this class.

Return Value

array

string getAssociationTargetClass(string $assocName)

Returns the target class name of the given association.

Parameters

string $assocName

Return Value

string

Exceptions

InvalidArgumentException

getAssociationMappedByTargetField($assocName)

{@inheritDoc}

Parameters

$assocName

isAssociationInverseSide($assocName)

{@inheritDoc}

Parameters

$assocName

isInheritedField($field)

Parameters

$field

isInheritedAssociation($field)

Parameters

$field

setParentClasses($classes)

Parameters

$classes

markInheritanceRoot()

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