PHP Class Doctrine\ODM\CouchDB\Mapping\ClassMetadata

Since: 1.0
Author: Benjamin Eberlei ([email protected])
Author: Lukas Kahwe Smith ([email protected])
Inheritance: extends Doctrine\ODM\CouchDB\Mapping\ClassMetadataInfo, implements Doctrine\Common\Persistence\Mapping\ClassMetadata
显示文件 Open project: doctrine/couchdb-odm Class Usage Examples

Public Properties

Property Type Description
$alsoLoadMethods array READ-ONLY: Array of fields to also load with a given method.
$associationsMappings array READ-ONLY
$attachmentDeclaredClass string | null If in an inheritance scenario the attachment field is on a super class, this is its name.
$attachmentField string Field that stores the attachments as a key->value array of file-names to attachment objects.
$customRepositoryClassName string (Optional).
$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.
$hasAttachments boolean
$idGenerator
$identifier READ-ONLY: The field name of the document identifier.
$inInheritanceHierachy READ-ONLY: Is this entity in an inheritance hierachy?
$indexed boolean Is this class indexed? If yes, then a findAll() query can be executed for this type.
$indexes array An array of indexed fields, accessible through a generic view shipped with Doctrine.
$isEmbeddedDocument boolean READ-ONLY: Whether this class describes the mapping of a embedded document.
$isMappedSuperclass boolean READ-ONLY: Whether this class describes the mapping of a mapped superclass.
$isReadOnly boolean This should be set to true for value objects, for example attachments. Replacing the reference with a new value object will trigger an update.
$isVersioned boolean CouchDB documents are always versioned, this flag determines if this version is exposed to the userland.
$jsonNames array An array of json result-key-names to field-names
$name READ-ONLY: The name of the document class.
$namespace string READ-ONLY: The namespace the document class is contained in.
$parentClasses READ-ONLY: a list of all parent classes.
$reflClass ReflectionClas\ReflectionClass The ReflectionClass instance of the mapped class.
$reflFields array The ReflectionProperty instances of the mapped class.
$rootDocumentName READ-ONLY: The root document class name.
$versionField string Version Field stores the CouchDB Revision

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.
__sleep ( ) : array Determines which fields get serialized.
deriveChildMetadata ( ClassMetadata $child ) Used to derive a class metadata of the current instance for a mapped child class.
getAssociationMappedByTargetField ( $assocName ) {@inheritDoc}
getAssociationNames ( ) : array A numerically indexed list of association names of this persistent class.
getAssociationTargetClass ( string $assocName ) : string Returns the target class name of the given association.
getFieldMapping ( string $fieldName ) : array Gets the mapping of a field.
getFieldNames ( ) : array A numerically indexed list of field names of this persistent class.
getFieldValue ( object $document, string $field ) Gets the specified field's value off the given document.
getIdentifier ( ) : string Gets the mapped identifier field of this class.
getIdentifierFieldNames ( ) : array Get identifier field names of this class.;
getIdentifierValue ( object $document ) : string Gets the document identifier.
getIdentifierValues ( object $document ) : array Get identifier values of this document.
getName ( ) : string The name of this Document class.
getNamespace ( ) : string The namespace this Document class belongs to.
getReflectionClass ( ) : ReflectionClas\ReflectionClass Gets the ReflectionClass instance of the mapped class.
getReflectionProperties ( ) : array Gets the ReflectionPropertys of the mapped class.
getReflectionProperty ( string $name ) : ReflectionPropert\ReflectionProperty Gets a ReflectionProperty for a specific field of the mapped class.
getTypeOfField ( string $fieldName ) : Type Gets the type of a field.
hasAssociation ( string $fieldName ) : boolean Checks if the given field is a mapped association for this class.
hasField ( $fieldName ) : boolean Checks whether the class has a (mapped) field with a certain name.
initializeReflection ( Doctrine\Common\Persistence\Mapping\ReflectionService $reflService ) : void Initializes a new ClassMetadata instance that will hold the object-relational mapping metadata of the class with the given name.
isAssociationInverseSide ( $assocName ) {@inheritDoc}
isCollectionValuedAssociation ( $name )
isIdentifier ( string $fieldName ) : boolean Checks whether a field is part of the identifier/primary key field(s).
isInheritedAssociation ( $field )
isInheritedField ( $field )
isSingleValuedAssociation ( string $fieldName ) : boolean Checks if the given field is a mapped single valued association for this class.
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.
mapManyToMany ( $mapping )
mapManyToOne ( $mapping )
markInheritanceRoot ( )
newInstance ( ) : object Creates a new instance of the mapped class, without invoking the constructor.
setCustomRepositoryClass ( string $repositoryClassName ) Registers a custom repository class for the document class.
setFieldValue ( object $document, string $field, mixed $value ) Sets the specified field to the specified value on the given document.
setIdentifier ( string $identifier ) INTERNAL: Sets the mapped identifier field of this class.
setIdentifierValue ( object $document, mixed $id ) Sets the document identifier of a document.
setParentClasses ( $classes )
wakeupReflection ( $reflService ) Restores some state that can not be serialized/unserialized.

Protected Methods

Method Description
validateAndCompleteAssociationMapping ( $mapping )
validateAndCompleteFieldMapping ( $mapping )
validateAndCompleteReferenceMapping ( $mapping )

Private Methods

Method Description
checkAndStoreIndexMapping ( $mapping )
storeAssociationMapping ( $mapping )

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.

__sleep() public method

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)
public __sleep ( ) : array
return array The names of all the fields that should be serialized.

deriveChildMetadata() public method

Used to derive a class metadata of the current instance for a mapped child class.
public deriveChildMetadata ( ClassMetadata $child )
$child ClassMetadata

getAssociationMappedByTargetField() public method

{@inheritDoc}
public getAssociationMappedByTargetField ( $assocName )

getAssociationNames() public method

This array includes identifier associations if present on this class.
public getAssociationNames ( ) : array
return array

getAssociationTargetClass() public method

Returns the target class name of the given association.
public getAssociationTargetClass ( string $assocName ) : string
$assocName string
return string

getFieldMapping() public method

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

getFieldNames() public method

This array includes identifier fields if present on this class.
public getFieldNames ( ) : array
return array

getFieldValue() public method

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

getIdentifier() public method

Gets the mapped identifier field of this class.
public getIdentifier ( ) : string
return string $identifier

getIdentifierFieldNames() public method

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

getIdentifierValue() public method

Gets the document identifier.
public getIdentifierValue ( object $document ) : string
$document object
return string $id

getIdentifierValues() public method

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.
public getIdentifierValues ( object $document ) : array
$document object
return array

getName() public method

The name of this Document class.
public getName ( ) : string
return string $name The Document class name.

getNamespace() public method

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

getReflectionClass() public method

Gets the ReflectionClass instance of the mapped class.
public getReflectionClass ( ) : ReflectionClas\ReflectionClass
return ReflectionClas\ReflectionClass

getReflectionProperties() public method

Gets the ReflectionPropertys 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 ) : ReflectionPropert\ReflectionProperty
$name string
return ReflectionPropert\ReflectionProperty

getTypeOfField() public method

Gets the type of a field.
public getTypeOfField ( string $fieldName ) : Type
$fieldName string
return Type

hasAssociation() public method

Checks if the given field is a mapped association for this class.
public hasAssociation ( string $fieldName ) : boolean
$fieldName string
return boolean

hasField() public method

Checks whether the class has a (mapped) field with a certain name.
public hasField ( $fieldName ) : boolean
$fieldName
return boolean

initializeReflection() public method

Initializes a new ClassMetadata instance that will hold the object-relational mapping metadata of the class with the given name.
public initializeReflection ( Doctrine\Common\Persistence\Mapping\ReflectionService $reflService ) : void
$reflService Doctrine\Common\Persistence\Mapping\ReflectionService The reflection service.
return void

isAssociationInverseSide() public method

{@inheritDoc}
public isAssociationInverseSide ( $assocName )

isCollectionValuedAssociation() public method

isIdentifier() public method

Checks whether a field is part of the identifier/primary key field(s).
public isIdentifier ( string $fieldName ) : boolean
$fieldName string The field name
return boolean TRUE if the field is part of the table identifier/primary key field(s), FALSE otherwise.

isInheritedAssociation() public method

public isInheritedAssociation ( $field )

isInheritedField() public method

public isInheritedField ( $field )

isSingleValuedAssociation() public method

Checks if the given field is a mapped single valued association for this class.
public isSingleValuedAssociation ( string $fieldName ) : boolean
$fieldName string
return boolean

mapAttachments() public method

Set the field that will contain attachments of this document.
public mapAttachments ( string $fieldName )
$fieldName string

mapEmbedded() public method

- 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?
public mapEmbedded ( array $mapping )
$mapping array

mapField() public method

- 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?
public mapField ( array $mapping )
$mapping array The mapping information.

mapManyToMany() public method

public mapManyToMany ( $mapping )

mapManyToOne() public method

public mapManyToOne ( $mapping )

markInheritanceRoot() public method

public markInheritanceRoot ( )

newInstance() public method

Creates a new instance of the mapped class, without invoking the constructor.
public newInstance ( ) : object
return object

setCustomRepositoryClass() public method

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

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

setIdentifier() public method

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

setIdentifierValue() public method

Sets the document identifier of a document.
public setIdentifierValue ( object $document, mixed $id )
$document object
$id mixed

setParentClasses() public method

public setParentClasses ( $classes )

validateAndCompleteAssociationMapping() protected method

protected validateAndCompleteAssociationMapping ( $mapping )

validateAndCompleteFieldMapping() protected method

protected validateAndCompleteFieldMapping ( $mapping )

validateAndCompleteReferenceMapping() protected method

protected validateAndCompleteReferenceMapping ( $mapping )

wakeupReflection() public method

Restores some state that can not be serialized/unserialized.
public wakeupReflection ( $reflService )

Property Details

$alsoLoadMethods public_oe property

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

$associationsMappings public_oe property

READ-ONLY
public array $associationsMappings
return array

$attachmentDeclaredClass public_oe property

If in an inheritance scenario the attachment field is on a super class, this is its name.
public string|null $attachmentDeclaredClass
return string | null

$attachmentField public_oe property

Field that stores the attachments as a key->value array of file-names to attachment objects.
public string $attachmentField
return string

$customRepositoryClassName public_oe property

(Optional).
public string $customRepositoryClassName
return string

$fieldMappings public_oe 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

$hasAttachments public_oe property

public bool $hasAttachments
return boolean

$idGenerator public_oe property

public $idGenerator

$identifier public_oe property

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

$inInheritanceHierachy public_oe property

READ-ONLY: Is this entity in an inheritance hierachy?
public $inInheritanceHierachy

$indexed public_oe property

Is this class indexed? If yes, then a findAll() query can be executed for this type.
public bool $indexed
return boolean

$indexes public_oe property

An array of indexed fields, accessible through a generic view shipped with Doctrine.
public array $indexes
return array

$isEmbeddedDocument public_oe property

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

$isMappedSuperclass public_oe property

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

$isReadOnly public_oe property

This should be set to true for value objects, for example attachments. Replacing the reference with a new value object will trigger an update.
public bool $isReadOnly
return boolean

$isVersioned public_oe property

CouchDB documents are always versioned, this flag determines if this version is exposed to the userland.
public bool $isVersioned
return boolean

$jsonNames public_oe property

An array of json result-key-names to field-names
public array $jsonNames
return array

$name public_oe property

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

$namespace public_oe property

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

$parentClasses public_oe property

READ-ONLY: a list of all parent classes.
public $parentClasses

$reflClass public_oe property

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

$reflFields public_oe property

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

$rootDocumentName public_oe property

READ-ONLY: The root document class name.
public $rootDocumentName

$versionField public_oe property

Version Field stores the CouchDB Revision
public string $versionField
return string