PHP Класс Doctrine\ODM\PHPCR\UnitOfWork

С версии: 1.0
Автор: Jordi Boggiano ([email protected])
Автор: Pascal Helfenstein ([email protected])
Автор: Lukas Kahwe Smith ([email protected])
Автор: Brian King ([email protected])
Автор: David Buchmann ([email protected])
Автор: Daniel Barsotti ([email protected])
Показать файл Открыть проект Примеры использования класса

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

Метод Описание
__construct ( Doctrine\ODM\PHPCR\DocumentManagerInterface $dm )
bindTranslation ( object $document, string $locale ) Bind the translatable fields of the document in the specified locale.
checkin ( $document ) Checkin operation - Save all current changes and then check in the Node by id.
checkout ( $document ) Check out operation - Save all current changes and then check out the Node by path.
checkpoint ( $document ) Create a version of the document and check it out right again to continue editing.
clear ( ) Clears the UnitOfWork.
commit ( object | array | null $document = null ) Commits the UnitOfWork
computeChangeSet ( ClassMetadata $class, object $document ) Computes changeset for a given document.
computeChangeSets ( ) Detects the changes that need to be persisted
computeSingleDocumentChangeSet ( object $document ) Detects the changes for a single document
contains ( object | string $document ) : boolean
createAssoc ( array $properties, array $mapping ) : array Create an associative array form the properties stored with the node
detach ( object $document ) Detaches a document from the persistence management. It's persistence will no longer be managed by Doctrine.
determineDocumentId ( object $document, ClassMetadata $metadata = null ) : string | null Try to determine the document id first by looking into the document, but if not mapped, look into the document id cache.
doLoadTranslation ( object $document, ClassMetadata $metadata, string $locale = null, boolean $fallback = false, boolean $refresh = false ) Load the translatable fields of the document.
findVersionByName ( $className, $id, $versionName )
getAllLinearVersions ( object $document, integer $limit ) : array Get the version history information for a document
getCurrentLocale ( object $document, ClassMetadata $metadata = null ) : string | null Determine the current locale of a managed document.
getDocumentById ( string $id ) : object | false Tries to find a document with the given id in the identity map of this UnitOfWork.
getDocumentId ( object | string $document, $throw = true ) : string | null Get the object ID for the given document
getDocumentState ( object $document ) : integer Get the state of this document
getLocalesFor ( object $document ) : array Get all locales in which this document currently exists in storage.
getOrCreateDocument ( null | string $className, PHPCR\NodeInterface $node, array &$hints = [] ) : object Get the existing document or proxy of the specified class and node data or create a new one if not existing.
getOrCreateDocuments ( null | string $className, Iterato\Iterator | array $nodes, array &$hints = [] ) : array Get the existing document or proxy of the specified class and node data or create a new one if not existing.
getOrCreateProxy ( string $targetId, string $className, string $locale = null ) : object Get the existing document or proxy for this id of this class, or create a new one.
getOrCreateProxyFromNode ( PHPCR\NodeInterface $node, string $locale = null ) : object Get the existing document or proxy or create a new one for this PHPCR Node
getPrefetchHelper ( )
getScheduledInserts ( ) : array Gets the currently scheduled document insertions in this UnitOfWork.
getScheduledMoves ( ) : array Gets the currently scheduled document moves in this UnitOfWork.
getScheduledRemovals ( ) : array Gets the currently scheduled document deletions in this UnitOfWork.
getScheduledReorders ( ) : array Gets the currently scheduled document reorders in this UnitOfWork.
getScheduledUpdates ( ) : array Gets the currently scheduled document updates in this UnitOfWork.
initializeObject ( $obj ) Helper method to initialize a lazy loading proxy or persistent collection.
invokeGlobalEvent ( $eventName, Doctrine\Common\EventArgs $event ) To invoke a global invent without using the ListenersInvoker.
isDocumentTranslatable ( ClassMetadata $metadata ) : boolean Determine whether this document is translatable.
isScheduledForInsert ( object $document ) : boolean Checks whether a document is scheduled for insertion.
merge ( $document )
persistNew ( ClassMetadata $class, object $document, $overrideIdGenerator = null, $parent = null ) Persist new document, marking it managed and generating the id and the node.
processAssoc ( PHPCR\NodeInterface $node, array $mapping, array $assoc ) : array Process null values in an associative array so that they can be stored in phpcr.
refresh ( $document )
refreshDocumentForProxy ( string $className, Doctrine\Common\Proxy\Proxy $document ) Populate the proxy with actual data
registerDocument ( object $document, string $id ) : string
removeAssoc ( PHPCR\NodeInterface $node, array $mapping ) Remove an associative array form the properties stored with the node
removeTranslation ( object $document, string $locale )
removeVersion ( string $documentVersion ) Delete an old version of a document
restoreVersion ( string $documentVersion, boolean $removeExisting ) Restore the document to the state it was before
scheduleInsert ( object $document ) Schedule insertion of this document and cascade if necessary.
scheduleMove ( $document, $targetPath )
scheduleRemove ( $document )
scheduleReorder ( $document, $srcName, $targetName, $before )
setFetchDepth ( integer | null $fetchDepth = null ) : integer Sets the fetch depth on the session if the PHPCR session instance supports it and returns the previous fetch depth value
setPrefetchHelper ( $helper )
validateClassName ( object $document, string | null $className ) Validate if a document is of the specified class, if the global setting to validate is activated.

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

Метод Описание
doLoadDatabaseTranslation ( object $document, ClassMetadata $metadata, string $locale, boolean $fallback, boolean $refresh ) : string Attempt to load translation from the database.
doLoadPendingTranslation ( object $document, ClassMetadata $metadata, string $locale ) : boolean Load an in-memory bound translation if there is one in the requested locale. Does not attempt any fallback.

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

Метод Описание
cascadeDetach ( ClassMetadata $class, object $document, array &$visited ) Cascades a detach operation to associated documents.
cascadeDoLoadTranslation ( object $document, array $mapping, string $locale )
cascadeMerge ( ClassMetadata $class, object $document, object $managedCopy, array &$visited ) Cascades a merge operation to associated entities.
cascadeMergeCollection ( $managedCol, array $mapping )
cascadeRefresh ( ClassMetadata $class, $document, &$visited )
cascadeRemove ( ClassMetadata $class, $document, &$visited )
cascadeScheduleInsert ( ClassMetadata $class, object $document, array &$visited )
cascadeScheduleParentInsert ( $class, $document, &$visited )
computeAssociationChanges ( object $document, string $class, string $oid, boolean $isNew, array $changeSet, string $assocType )
computeChildChanges ( array $mapping, mixed $child, string $parentId, string $nodename, mixed $parent = null ) : object Computes the changes of a child.
computeChildrenChanges ( object $document, string $class, string $oid, boolean $isNew, array $changeSet )
computeReferenceChanges ( array $mapping, mixed $reference ) Computes the changes of a reference.
computeReferrerChanges ( array $mapping, mixed $referrer ) Computes the changes of a referrer.
doBindTranslation ( object $document, string $locale, ClassMetadata $class )
doDetach ( object $document, array &$visited ) Executes a detach operation on the given document.
doMerge ( $document, array &$visited, $prevManagedCopy = null, $assoc = null )
doMergeSingleDocumentProperty ( $managedCopy, $document, ReflectionProperty $prop, array $mapping )
doRefresh ( $document, &$visited )
doRemove ( $document, &$visited )
doRemoveAllTranslations ( object $document, ClassMetadata $metadata )
doSaveTranslation ( $document, PHPCR\NodeInterface $node, $metadata )
doScheduleInsert ( $document, &$visited, $overrideIdGenerator = null )
executeInserts ( array $documents ) Executes all document insertions
executeMoves ( array $documents ) Executes all document moves
executeRemovals ( array $documents ) Executes all document removals
executeReorders ( $documents ) Execute reorderings
executeUpdates ( array $documents, boolean $dispatchEvents = true ) Executes all document updates
generateUuid ( ) : string
getChildNodename ( string $parentId, string $nodename, object $child, object $parent ) : mixed | string Determine the nodename of a child in a children list.
getDocumentActualData ( ClassMetadata $class, object $document ) : array Get a documents actual data, flattening all the objects to arrays.
getIdGenerator ( string $type ) : Doctrine\ODM\PHPCR\Id\IdGenerator
getReferenceManyCollectionTypeFromMetadata ( $referenceFieldMetadata ) : string Extracts ReferenceManyCollection type from field metadata
getVersionedNodePath ( $document )
isAutocreatedProperty ( ClassMetadata $class, string $fieldName ) : boolean Identify whether a PHPCR property is autocreated or not.
isTranslationRemoved ( object $document, string $locale ) : boolean Checks if the translation was removed Note it also returns true if the document isn't translated or was not translated into the given locale, ie.
objToStr ( $obj, Doctrine\ODM\PHPCR\DocumentManagerInterface $dm = null )
purgeChildren ( object $document ) recurse over all known child documents to remove them form this unit of work as their parent gets removed from phpcr. If you do not, flush will try to create orphaned nodes if these documents are modified which leads to a PHPCR exception
setDocumentState ( object | string $document, integer $state )
setLocale ( object $document, ClassMetadata $metadata, string $locale )
setMixins ( ClassMetadata $metadata, PHPCR\NodeInterface $node, object $document ) Set the mapped mixins.
unregisterDocument ( object $document ) Removes a document from the identity map. This effectively detaches the document from the persistence management of Doctrine.
validateChildClass ( PHPCR\NodeInterface $parentNode, ClassMetadata $class ) If the parent node has child restrictions, ensure that the given class name is within them.

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

__construct() публичный метод

public __construct ( Doctrine\ODM\PHPCR\DocumentManagerInterface $dm )
$dm Doctrine\ODM\PHPCR\DocumentManagerInterface

bindTranslation() публичный метод

This method will update the field mapped to Locale if it does not match the $locale argument.
public bindTranslation ( object $document, string $locale )
$document object the document to persist a translation of
$locale string the locale this document currently has

checkin() публичный метод

Checkin operation - Save all current changes and then check in the Node by id.
public checkin ( $document )

checkout() публичный метод

Check out operation - Save all current changes and then check out the Node by path.
public checkout ( $document )

checkpoint() публичный метод

Create a version of the document and check it out right again to continue editing.
public checkpoint ( $document )

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

Clears the UnitOfWork.
public clear ( )

commit() публичный метод

Commits the UnitOfWork
public commit ( object | array | null $document = null )
$document object | array | null optionally limit to a specific document or an array of documents

computeChangeSet() публичный метод

Computes changeset for a given document.
public computeChangeSet ( ClassMetadata $class, object $document )
$class Doctrine\ODM\PHPCR\Mapping\ClassMetadata
$document object

computeChangeSets() публичный метод

Detects the changes that need to be persisted
public computeChangeSets ( )

computeSingleDocumentChangeSet() публичный метод

Detects the changes for a single document
public computeSingleDocumentChangeSet ( object $document )
$document object

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

public contains ( object | string $document ) : boolean
$document object | string document instance or document object hash
Результат boolean

createAssoc() публичный метод

Create an associative array form the properties stored with the node
public createAssoc ( array $properties, array $mapping ) : array
$properties array the node's properties
$mapping array the field's mapping information
Результат array

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

Detaches a document from the persistence management. It's persistence will no longer be managed by Doctrine.
public detach ( object $document )
$document object The document to detach.

determineDocumentId() публичный метод

Try to determine the document id first by looking into the document, but if not mapped, look into the document id cache.
public determineDocumentId ( object $document, ClassMetadata $metadata = null ) : string | null
$document object
$metadata Doctrine\ODM\PHPCR\Mapping\ClassMetadata
Результат string | null the current or stored id, or null if nothing can be found.

doLoadDatabaseTranslation() защищенный метод

If $fallback is true, goes over the locales as provided by the locale chooser strategy to find the best language, each time first checking for a pending translation. If no translation is found at all, the translated fields are set to null and the requested locale is considered to be the one found.
См. также: doLoadTranslation
protected doLoadDatabaseTranslation ( object $document, ClassMetadata $metadata, string $locale, boolean $fallback, boolean $refresh ) : string
$document object
$metadata Doctrine\ODM\PHPCR\Mapping\ClassMetadata
$locale string The desired locale.
$fallback boolean Whether to perform language fallback.
$refresh boolean Whether to force reloading the translation.
Результат string The locale used

doLoadPendingTranslation() защищенный метод

Load an in-memory bound translation if there is one in the requested locale. Does not attempt any fallback.
См. также: doLoadTranslation
protected doLoadPendingTranslation ( object $document, ClassMetadata $metadata, string $locale ) : boolean
$document object
$metadata Doctrine\ODM\PHPCR\Mapping\ClassMetadata
$locale string
Результат boolean whether the pending translation in language $locale was loaded or not.

doLoadTranslation() публичный метод

If locale is not set then the current locale of the document is reloaded, resetting possible changes. If the document is not translatable, this method returns immediately and without error.
public doLoadTranslation ( object $document, ClassMetadata $metadata, string $locale = null, boolean $fallback = false, boolean $refresh = false )
$document object
$metadata Doctrine\ODM\PHPCR\Mapping\ClassMetadata
$locale string The locale to use or null if the default locale should be used
$fallback boolean Whether to do try other languages
$refresh boolean

findVersionByName() публичный метод

См. также: DocumentManager::findVersionByName
public findVersionByName ( $className, $id, $versionName )

getAllLinearVersions() публичный метод

TODO: implement labels once jackalope implements them, until then labels will be an empty array. TODO: implement limit
public getAllLinearVersions ( object $document, integer $limit ) : array
$document object the document of which to get the version history
$limit integer an optional limit to only get the latest $limit information
Результат array of => array("name" => , "labels" => , "created" => ) oldest version first

getCurrentLocale() публичный метод

If the document is not translatable, null is returned. If the document is translatable and the locale is mapped onto a document field, the value of that field is returned. Otherwise the UnitOfWork information on locales for documents without a locale mapping is consulted. If nothing matches (for example when this is a detached document), the default locale of the LocaleChooserStrategy is returned.
public getCurrentLocale ( object $document, ClassMetadata $metadata = null ) : string | null
$document object the managed document to get the locale for
$metadata Doctrine\ODM\PHPCR\Mapping\ClassMetadata document metadata, optional
Результат string | null the current locale of $document or null if it is not translatable

getDocumentById() публичный метод

Tries to find a document with the given id in the identity map of this UnitOfWork.
public getDocumentById ( string $id ) : object | false
$id string The document id to look for.
Результат object | false Returns the document with the specified id if it exists in this UnitOfWork, FALSE otherwise.

getDocumentId() публичный метод

Get the object ID for the given document
public getDocumentId ( object | string $document, $throw = true ) : string | null
$document object | string document instance or document object hash
Результат string | null

getDocumentState() публичный метод

STATE_NEW: the document is not persisted, but a valid mapped document STATE_MANAGED: the document is tracked and will be updated on flush STATE_REMOVED: the document is scheduled for removal STATE_DETACHED: there is a corresponding Node in storage, but this document is not bound to it
public getDocumentState ( object $document ) : integer
$document object the document to get the state of
Результат integer one of the STATE_* constants of this class

getLocalesFor() публичный метод

Get all locales in which this document currently exists in storage.
public getLocalesFor ( object $document ) : array
$document object A managed document
Результат array list of locales of this document

getOrCreateDocument() публичный метод

Supported hints are - refresh: reload the fields from the database if set - locale: use this locale instead of the one from the annotation or the default - fallback: whether to try other languages or throw a not found exception if the desired locale is not found. defaults to true if not set and locale is not given either. - prefetch: if set to false, do not attempt to prefetch related data. (This makes sense when the caller already did this beforehand.)
public getOrCreateDocument ( null | string $className, PHPCR\NodeInterface $node, array &$hints = [] ) : object
$className null | string
$node PHPCR\NodeInterface
$hints array
Результат object

getOrCreateDocuments() публичный метод

Supported hints are - refresh: reload the fields from the database if set - locale: use this locale instead of the one from the annotation or the default - fallback: whether to try other languages or throw a not found exception if the desired locale is not found. defaults to true if not set and locale is not given either. - prefetch: if set to false, do not attempt to prefetch related data. (This makes sense when the caller already did this beforehand.)
public getOrCreateDocuments ( null | string $className, Iterato\Iterator | array $nodes, array &$hints = [] ) : array
$className null | string
$nodes Iterato\Iterator | array
$hints array
Результат array

getOrCreateProxy() публичный метод

Get the existing document or proxy for this id of this class, or create a new one.
public getOrCreateProxy ( string $targetId, string $className, string $locale = null ) : object
$targetId string
$className string
$locale string
Результат object

getOrCreateProxyFromNode() публичный метод

Get the existing document or proxy or create a new one for this PHPCR Node
public getOrCreateProxyFromNode ( PHPCR\NodeInterface $node, string $locale = null ) : object
$node PHPCR\NodeInterface
$locale string
Результат object

getPrefetchHelper() публичный метод

public getPrefetchHelper ( )

getScheduledInserts() публичный метод

Gets the currently scheduled document insertions in this UnitOfWork.
public getScheduledInserts ( ) : array
Результат array

getScheduledMoves() публичный метод

Gets the currently scheduled document moves in this UnitOfWork.
public getScheduledMoves ( ) : array
Результат array

getScheduledRemovals() публичный метод

Gets the currently scheduled document deletions in this UnitOfWork.
public getScheduledRemovals ( ) : array
Результат array

getScheduledReorders() публичный метод

Gets the currently scheduled document reorders in this UnitOfWork.
public getScheduledReorders ( ) : array
Результат array

getScheduledUpdates() публичный метод

Gets the currently scheduled document updates in this UnitOfWork.
public getScheduledUpdates ( ) : array
Результат array

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

Helper method to initialize a lazy loading proxy or persistent collection.
public initializeObject ( $obj )

invokeGlobalEvent() публичный метод

To invoke a global invent without using the ListenersInvoker.
public invokeGlobalEvent ( $eventName, Doctrine\Common\EventArgs $event )
$eventName
$event Doctrine\Common\EventArgs

isDocumentTranslatable() публичный метод

To be translatable, it needs a translation strategy and have at least one translated field.
public isDocumentTranslatable ( ClassMetadata $metadata ) : boolean
$metadata Doctrine\ODM\PHPCR\Mapping\ClassMetadata the document meta data
Результат boolean

isScheduledForInsert() публичный метод

Checks whether a document is scheduled for insertion.
public isScheduledForInsert ( object $document ) : boolean
$document object
Результат boolean

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

public merge ( $document )

persistNew() публичный метод

This method is either called through DocumentManager#persist() or during DocumentManager#flush(), when persistence by reachability is applied.
public persistNew ( ClassMetadata $class, object $document, $overrideIdGenerator = null, $parent = null )
$class Doctrine\ODM\PHPCR\Mapping\ClassMetadata
$document object

processAssoc() публичный метод

Stores keys and null fields in the node and returns the processed values
public processAssoc ( PHPCR\NodeInterface $node, array $mapping, array $assoc ) : array
$node PHPCR\NodeInterface the node where to store the assoc array
$mapping array the field's mapping
$assoc array the associative array
Результат array

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

public refresh ( $document )

refreshDocumentForProxy() публичный метод

Populate the proxy with actual data
public refreshDocumentForProxy ( string $className, Doctrine\Common\Proxy\Proxy $document )
$className string
$document Doctrine\Common\Proxy\Proxy

registerDocument() публичный метод

public registerDocument ( object $document, string $id ) : string
$document object
$id string The document id to look for.
Результат string generated object hash

removeAssoc() публичный метод

Remove an associative array form the properties stored with the node
public removeAssoc ( PHPCR\NodeInterface $node, array $mapping )
$node PHPCR\NodeInterface the node where to store the assoc array
$mapping array the field's mapping

removeTranslation() публичный метод

public removeTranslation ( object $document, string $locale )
$document object
$locale string

removeVersion() публичный метод

Delete an old version of a document
public removeVersion ( string $documentVersion )
$documentVersion string the version name

restoreVersion() публичный метод

Restore the document to the state it was before
См. также: VersionManager::restore
public restoreVersion ( string $documentVersion, boolean $removeExisting )
$documentVersion string the version name to restore
$removeExisting boolean how to handle identifier collisions

scheduleInsert() публичный метод

Schedule insertion of this document and cascade if necessary.
public scheduleInsert ( object $document )
$document object

scheduleMove() публичный метод

public scheduleMove ( $document, $targetPath )

scheduleRemove() публичный метод

public scheduleRemove ( $document )

scheduleReorder() публичный метод

public scheduleReorder ( $document, $srcName, $targetName, $before )

setFetchDepth() публичный метод

Sets the fetch depth on the session if the PHPCR session instance supports it and returns the previous fetch depth value
public setFetchDepth ( integer | null $fetchDepth = null ) : integer
$fetchDepth integer | null
Результат integer previous fetch depth value

setPrefetchHelper() публичный метод

public setPrefetchHelper ( $helper )

validateClassName() публичный метод

Validate if a document is of the specified class, if the global setting to validate is activated.
public validateClassName ( object $document, string | null $className )
$document object
$className string | null The class name $document must be instanceof. Pass empty to not validate anything.