PHP Класс Doctrine\ODM\MongoDB\DocumentManager

С версии: 1.0
Автор: Jonathan H. Wage ([email protected])
Автор: Roman Borschel ([email protected])
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
clear ( string | null $documentName = null ) Clears the DocumentManager.
close ( ) Closes the DocumentManager. All documents that are currently managed by this DocumentManager become detached. The DocumentManager may no longer be used after it is closed.
contains ( object $document ) : boolean Determines whether a document instance is managed in this DocumentManager.
create ( Connection $conn = null, Configuration $config = null, Doctrine\Common\EventManager $eventManager = null ) : DocumentManager Creates a new Document that operates on the given Mongo connection and uses the given Configuration.
createAggregationBuilder ( string $documentName ) : Builder Creates a new aggregation builder instance for a class.
createDBRef ( mixed $document, array $referenceMapping = null ) : array Returns a DBRef array for the supplied document.
createQueryBuilder ( string $documentName = null ) : Query\Builder Create a new Query instance for a class.
detach ( object $document ) Detaches a document from the DocumentManager, causing a managed document to become detached. Unflushed changes made to the document if any (including removal of the document), will not be synchronized to the database.
find ( string $documentName, mixed $identifier, integer $lockMode = LockMode::NONE, integer $lockVersion = null ) : object Finds a Document by its identifier.
flush ( object $document = null, array $options = [] ) Flushes all changes to objects that have been queued up to now to the database.
getClassMetadata ( string $className ) : ClassMetadata Returns the metadata for a class.
getConfiguration ( ) : Configuration Gets the Configuration used by the DocumentManager.
getConnection ( ) : Connection Gets the PHP Mongo instance that this DocumentManager wraps.
getDocumentCollection ( string $className ) : Doctrine\MongoDB\Collection Returns the MongoCollection instance for a class.
getDocumentCollections ( ) : array Gets the array of instantiated document collection instances.
getDocumentDatabase ( string $className ) : Doctrine\MongoDB\Database Returns the MongoDB instance for a class.
getDocumentDatabases ( ) : array Gets the array of instantiated document database instances.
getEventManager ( ) : Doctrine\Common\EventManager Gets the EventManager used by the DocumentManager.
getFilterCollection ( ) : Doctrine\ODM\MongoDB\Query\FilterCollection Gets the filter collection.
getHydratorFactory ( ) : Doctrine\ODM\MongoDB\Hydrator\HydratorInterface Gets the Hydrator factory used by the DocumentManager to generate and get hydrators for each type of document.
getMetadataFactory ( ) : ClassMetadataFactory Gets the metadata factory used to gather the metadata of classes.
getPartialReference ( string $documentName, mixed $identifier ) : object Gets a partial reference to the document identified by the given type and identifier without actually loading it, if the document is not yet loaded.
getProxyFactory ( ) : ProxyFactory Gets the proxy factory used by the DocumentManager to create document proxies.
getReference ( string $documentName, string | object $identifier ) : mixed | object Gets a reference to the document identified by the given type and identifier without actually loading it.
getRepository ( string $documentName ) : DocumentRepository Gets the repository for a document class.
getSchemaManager ( ) : SchemaManager Returns SchemaManager, used to create/drop indexes/collections/databases.
getUnitOfWork ( ) : UnitOfWork Gets the UnitOfWork used by the DocumentManager to coordinate operations.
initializeObject ( object $obj ) Helper method to initialize a lazy loading proxy or persistent collection.
isOpen ( ) : boolean Check if the Document manager is open or closed.
lock ( object $document, integer $lockMode, integer $lockVersion = null ) Acquire a lock on the given document.
merge ( object $document ) : object Merges the state of a detached document into the persistence context of this DocumentManager and returns the managed copy of the document.
persist ( object $document ) Tells the DocumentManager to make an instance managed and persistent.
refresh ( object $document ) Refreshes the persistent state of a document from the database, overriding any local changes that have not yet been persisted.
remove ( object $document ) Removes a document instance.
unlock ( object $document ) Releases a lock on the given document.

Защищенные методы

Метод Описание
__construct ( Connection $conn = null, Configuration $config = null, Doctrine\Common\EventManager $eventManager = null ) Creates a new Document that operates on the given Mongo connection and uses the given Configuration.

Приватные методы

Метод Описание
errorIfClosed ( ) Throws an exception if the DocumentManager is closed or currently not active.

Описание методов

__construct() защищенный Метод

Creates a new Document that operates on the given Mongo connection and uses the given Configuration.
protected __construct ( Connection $conn = null, Configuration $config = null, Doctrine\Common\EventManager $eventManager = null )
$conn Doctrine\MongoDB\Connection
$config Configuration
$eventManager Doctrine\Common\EventManager

clear() публичный Метод

All documents that are currently managed by this DocumentManager become detached.
public clear ( string | null $documentName = null )
$documentName string | null if given, only documents of this type will get detached

close() публичный Метод

Closes the DocumentManager. All documents that are currently managed by this DocumentManager become detached. The DocumentManager may no longer be used after it is closed.
public close ( )

contains() публичный Метод

Determines whether a document instance is managed in this DocumentManager.
public contains ( object $document ) : boolean
$document object
Результат boolean TRUE if this DocumentManager currently manages the given document, FALSE otherwise.

create() публичный статический Метод

Creates a new Document that operates on the given Mongo connection and uses the given Configuration.
public static create ( Connection $conn = null, Configuration $config = null, Doctrine\Common\EventManager $eventManager = null ) : DocumentManager
$conn Doctrine\MongoDB\Connection
$config Configuration
$eventManager Doctrine\Common\EventManager
Результат DocumentManager

createAggregationBuilder() публичный Метод

Creates a new aggregation builder instance for a class.
public createAggregationBuilder ( string $documentName ) : Builder
$documentName string The document class name.
Результат Doctrine\ODM\MongoDB\Aggregation\Builder

createDBRef() публичный Метод

Returns a DBRef array for the supplied document.
public createDBRef ( mixed $document, array $referenceMapping = null ) : array
$document mixed A document object
$referenceMapping array Mapping for the field that references the document
Результат array A DBRef array

createQueryBuilder() публичный Метод

Create a new Query instance for a class.
public createQueryBuilder ( string $documentName = null ) : Query\Builder
$documentName string The document class name.
Результат Query\Builder

detach() публичный Метод

Documents which previously referenced the detached document will continue to reference it.
public detach ( object $document )
$document object The document to detach.

find() публичный Метод

This is just a convenient shortcut for getRepository($documentName)->find($id).
public find ( string $documentName, mixed $identifier, integer $lockMode = LockMode::NONE, integer $lockVersion = null ) : object
$documentName string
$identifier mixed
$lockMode integer
$lockVersion integer
Результат object $document

flush() публичный Метод

This effectively synchronizes the in-memory state of managed objects with the database.
public flush ( object $document = null, array $options = [] )
$document object
$options array Array of options to be used with batchInsert(), update() and remove()

getClassMetadata() публичный Метод

Returns the metadata for a class.
public getClassMetadata ( string $className ) : ClassMetadata
$className string The class name.
Результат Doctrine\ODM\MongoDB\Mapping\ClassMetadata

getConfiguration() публичный Метод

Gets the Configuration used by the DocumentManager.
public getConfiguration ( ) : Configuration
Результат Configuration

getConnection() публичный Метод

Gets the PHP Mongo instance that this DocumentManager wraps.
public getConnection ( ) : Connection
Результат Doctrine\MongoDB\Connection

getDocumentCollection() публичный Метод

Returns the MongoCollection instance for a class.
public getDocumentCollection ( string $className ) : Doctrine\MongoDB\Collection
$className string The class name.
Результат Doctrine\MongoDB\Collection

getDocumentCollections() публичный Метод

Gets the array of instantiated document collection instances.
public getDocumentCollections ( ) : array
Результат array

getDocumentDatabase() публичный Метод

Returns the MongoDB instance for a class.
public getDocumentDatabase ( string $className ) : Doctrine\MongoDB\Database
$className string The class name.
Результат Doctrine\MongoDB\Database

getDocumentDatabases() публичный Метод

Gets the array of instantiated document database instances.
public getDocumentDatabases ( ) : array
Результат array

getEventManager() публичный Метод

Gets the EventManager used by the DocumentManager.
public getEventManager ( ) : Doctrine\Common\EventManager
Результат Doctrine\Common\EventManager

getFilterCollection() публичный Метод

Gets the filter collection.
public getFilterCollection ( ) : Doctrine\ODM\MongoDB\Query\FilterCollection
Результат Doctrine\ODM\MongoDB\Query\FilterCollection The active filter collection.

getHydratorFactory() публичный Метод

Gets the Hydrator factory used by the DocumentManager to generate and get hydrators for each type of document.
public getHydratorFactory ( ) : Doctrine\ODM\MongoDB\Hydrator\HydratorInterface
Результат Doctrine\ODM\MongoDB\Hydrator\HydratorInterface

getMetadataFactory() публичный Метод

Gets the metadata factory used to gather the metadata of classes.
public getMetadataFactory ( ) : ClassMetadataFactory
Результат Doctrine\ODM\MongoDB\Mapping\ClassMetadataFactory

getPartialReference() публичный Метод

The returned reference may be a partial object if the document is not yet loaded/managed. If it is a partial object it will not initialize the rest of the document state on access. Thus you can only ever safely access the identifier of a document obtained through this method. The use-cases for partial references involve maintaining bidirectional associations without loading one side of the association or to update a document without loading it. Note, however, that in the latter case the original (persistent) document data will never be visible to the application (especially not event listeners) as it will never be loaded in the first place.
public getPartialReference ( string $documentName, mixed $identifier ) : object
$documentName string The name of the document type.
$identifier mixed The document identifier.
Результат object The (partial) document reference.

getProxyFactory() публичный Метод

Gets the proxy factory used by the DocumentManager to create document proxies.
public getProxyFactory ( ) : ProxyFactory
Результат Doctrine\ODM\MongoDB\Proxy\ProxyFactory

getReference() публичный Метод

If partial objects are allowed, this method will return a partial object that only has its identifier populated. Otherwise a proxy is returned that automatically loads itself on first access.
public getReference ( string $documentName, string | object $identifier ) : mixed | object
$documentName string
$identifier string | object
Результат mixed | object The document reference.

getRepository() публичный Метод

Gets the repository for a document class.
public getRepository ( string $documentName ) : DocumentRepository
$documentName string The name of the Document.
Результат DocumentRepository The repository.

getSchemaManager() публичный Метод

Returns SchemaManager, used to create/drop indexes/collections/databases.
public getSchemaManager ( ) : SchemaManager
Результат SchemaManager

getUnitOfWork() публичный Метод

Gets the UnitOfWork used by the DocumentManager to coordinate operations.
public getUnitOfWork ( ) : UnitOfWork
Результат UnitOfWork

initializeObject() публичный Метод

This method is a no-op for other objects.
public initializeObject ( object $obj )
$obj object

isOpen() публичный Метод

Check if the Document manager is open or closed.
public isOpen ( ) : boolean
Результат boolean

lock() публичный Метод

Acquire a lock on the given document.
public lock ( object $document, integer $lockMode, integer $lockVersion = null )
$document object
$lockMode integer
$lockVersion integer

merge() публичный Метод

The document passed to merge will not become associated/managed with this DocumentManager.
public merge ( object $document ) : object
$document object The detached document to merge into the persistence context.
Результат object The managed copy of the document.

persist() публичный Метод

The document will be entered into the database at or before transaction commit or as a result of the flush operation. NOTE: The persist operation always considers documents that are not yet known to this DocumentManager as NEW. Do not pass detached documents to the persist operation.
public persist ( object $document )
$document object The instance to make managed and persistent.

refresh() публичный Метод

Refreshes the persistent state of a document from the database, overriding any local changes that have not yet been persisted.
public refresh ( object $document )
$document object The document to refresh.

remove() публичный Метод

A removed document will be removed from the database at or before transaction commit or as a result of the flush operation.
public remove ( object $document )
$document object The document instance to remove.

unlock() публичный Метод

Releases a lock on the given document.
public unlock ( object $document )
$document object