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])
파일 보기 프로젝트 열기: doctrine/phpcr-odm 1 사용 예제들

공개 메소드들

메소드 설명
__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.