PHP Class Doctrine\OXM\UnitOfWork

This UnitOfWork is only capable of persisting xml class which are mapped via the @XmlRootEntity element. This ensures that @XmlId fields exist, and the persister knows how to save the xml correctly.
Since: 2.0
Author: Richard Fullmer ([email protected])
Inheritance: implements Doctrine\Common\PropertyChangedListener
Show file Open project: doctrine/oxm

Public Methods

Method Description
__construct ( XmlEntityManager $xem ) Initializes a new UnitOfWork instance, bound to the given EntityManager.
addToIdentityMap ( object $xmlEntity ) : boolean INTERNAL: Registers an document in the identity map.
clear ( ) Clears the UnitOfWork.
commit ( array $options = [] )
detach ( object $xmlEntity ) Detaches an xml-entity from the persistence management. It's persistence will no longer be managed by Doctrine.
getXmlEntityPersister ( string $entityName ) : RootXmlEntityPersister Gets the EntityPersister for an Entity.
getXmlEntityState ( object $xmlEntity, integer $assume = null ) : integer Gets the state of an xml entity within the current unit of work.
isInIdentityMap ( object $entity ) : boolean Checks whether an entity is registered in the identity map of this UnitOfWork.
isScheduledForInsert ( object $entity ) : boolean Checks whether an entity is scheduled for insertion.
merge ( object $xmlEntity ) : object Merges the state of the given detached xml-entity into this UnitOfWork.
persist ( object $xmlEntity ) Persists an xml entity as part of the current unit of work.
propertyChanged ( $entity, string $propertyName, mixed $oldValue, mixed $newValue ) Notifies the listener of a property change.
refresh ( $xmlEntity )
remove ( $xmlEntity )
removeFromIdentityMap ( object $entity ) : boolean INTERNAL: Removes an entity from the identity map. This effectively detaches the entity from the persistence management of Doctrine.
scheduleForDelete ( object $xmlEntity ) INTERNAL: Schedules an entity for deletion.
scheduleForDirtyCheck ( object $xmlEntity ) Schedules a xml entity for dirty-checking at commit-time.
scheduleForInsert ( object $xmlEntity ) Schedules an document for insertion into the database.
tryGetById ( string $id, string $rootClassName ) : mixed INTERNAL: Tries to get an document by its identifier hash. If no document is found for the given hash, FALSE is returned.

Private Methods

Method Description
doDetach ( object $xmlEntity, array &$visited ) Executes a detach operation on the given xml-entity.
doPersist ( object $xmlEntity, array &$visited ) Saves an document as part of the current unit of work.
doRefresh ( object $xmlEntity, array &$visited ) Executes a refresh operation on an xml-entity.
doRemove ( $xmlEntity, array &$visited )
executeDeletions ( ClassMetadata $class, array $options = [] ) Executes all document deletions for documents of the specified type.
executeInserts ( ClassMetadata $class, array $options = [] ) Executes all document insertions for documents of the specified type.
executeUpdates ( ClassMetadata $class, array $options = [] ) Executes all xml entity updates for documents of the specified type.
persistNew ( ClassMetadata $class, $xmlEntity ) : void

Method Details

__construct() public method

Initializes a new UnitOfWork instance, bound to the given EntityManager.
public __construct ( XmlEntityManager $xem )
$xem XmlEntityManager

addToIdentityMap() public method

Note that documents in a hierarchy are registered with the class name of the root document.
public addToIdentityMap ( object $xmlEntity ) : boolean
$xmlEntity object The document to register.
return boolean TRUE if the registration was successful, FALSE if the identity of the document in question is already managed.

clear() public method

Clears the UnitOfWork.
public clear ( )

commit() public method

public commit ( array $options = [] )
$options array

detach() public method

Detaches an xml-entity from the persistence management. It's persistence will no longer be managed by Doctrine.
public detach ( object $xmlEntity )
$xmlEntity object The xml-entity to detach.

getXmlEntityPersister() public method

Gets the EntityPersister for an Entity.
public getXmlEntityPersister ( string $entityName ) : RootXmlEntityPersister
$entityName string The name of the Entity.
return Doctrine\OXM\Persisters\RootXmlEntityPersister

getXmlEntityState() public method

NOTE: This method sees xml entities that are not MANAGED or REMOVED and have a populated identifier, whether it is generated or manually assigned, as DETACHED. This can be incorrect for manually assigned identifiers.
public getXmlEntityState ( object $xmlEntity, integer $assume = null ) : integer
$xmlEntity object
$assume integer The state to assume if the state is not yet known. This is usually used to avoid costly state lookups, in the worst case with a filesystem lookup.
return integer The document state.

isInIdentityMap() public method

Checks whether an entity is registered in the identity map of this UnitOfWork.
public isInIdentityMap ( object $entity ) : boolean
$entity object
return boolean

isScheduledForInsert() public method

Checks whether an entity is scheduled for insertion.
public isScheduledForInsert ( object $entity ) : boolean
$entity object
return boolean

merge() public method

Merges the state of the given detached xml-entity into this UnitOfWork.
public merge ( object $xmlEntity ) : object
$xmlEntity object
return object The managed copy of the xml-entity.

persist() public method

Persists an xml entity as part of the current unit of work.
public persist ( object $xmlEntity )
$xmlEntity object The xml entity to persist.

propertyChanged() public method

Notifies the listener of a property change.
public propertyChanged ( $entity, string $propertyName, mixed $oldValue, mixed $newValue )
$propertyName string The name of the property that changed.
$oldValue mixed The old value of the property that changed.
$newValue mixed The new value of the property that changed.

refresh() public method

public refresh ( $xmlEntity )

remove() public method

public remove ( $xmlEntity )

removeFromIdentityMap() public method

INTERNAL: Removes an entity from the identity map. This effectively detaches the entity from the persistence management of Doctrine.
public removeFromIdentityMap ( object $entity ) : boolean
$entity object
return boolean

scheduleForDelete() public method

INTERNAL: Schedules an entity for deletion.
public scheduleForDelete ( object $xmlEntity )
$xmlEntity object

scheduleForDirtyCheck() public method

Schedules a xml entity for dirty-checking at commit-time.
public scheduleForDirtyCheck ( object $xmlEntity )
$xmlEntity object The xml entity to schedule for dirty-checking.

scheduleForInsert() public method

If the document already has an identifier, it will be added to the identity map.
public scheduleForInsert ( object $xmlEntity )
$xmlEntity object The document to schedule for insertion.

tryGetById() public method

INTERNAL: Tries to get an document by its identifier hash. If no document is found for the given hash, FALSE is returned.
public tryGetById ( string $id, string $rootClassName ) : mixed
$id string
$rootClassName string
return mixed The found document or FALSE.