| Methods |
public
|
__construct(EntityManagerInterface $em)
Initializes a new UnitOfWork instance, bound to the given EntityManager.
Initializes a new UnitOfWork instance, bound to the given EntityManager.
|
#
|
public
|
commit(object|mixed[]|null $entity = null): void
Commits the UnitOfWork, executing all operations that have been postponed
up to this point. The state of all managed…
Commits the UnitOfWork, executing all operations that have been postponed
up to this point. The state of all managed entities will be synchronized with
the database.
The operations are executed in the following order:
- All entity insertions
- All entity updates
- All collection deletions
- All collection updates
- All entity deletions
Throws
|
#
|
private
|
postCommitCleanup(object|object[]|null $entity): void
|
#
|
private
|
computeScheduleInsertsChangeSets(): void
Computes the changesets of all entities scheduled for insertion.
Computes the changesets of all entities scheduled for insertion.
|
#
|
private
|
computeSingleEntityChangeSet(object $entity): void
Only flushes the given entity according to a ruleset that keeps the UoW consistent.
Only flushes the given entity according to a ruleset that keeps the UoW consistent.
- All entities scheduled for insertion, (orphan) removals and changes in collections are processed as well!
- Read Only entities are skipped.
- Proxies are skipped.
- Only if entity is properly managed.
Throws
|
#
|
private
|
executeExtraUpdates(): void
Executes any extra updates that have been scheduled.
Executes any extra updates that have been scheduled.
|
#
|
public
&
|
getEntityChangeSet(object $entity): mixed[][]
Gets the changeset for an entity.
Gets the changeset for an entity.
|
#
|
public
|
computeChangeSet<T is object>(ClassMetadata<T> $class, T $entity): void
Computes the changes that happened to a single entity.
Computes the changes that happened to a single entity.
Modifies/populates the following properties:
{@link _originalEntityData}
If the entity is NEW or MANAGED but not yet fully persisted (only has an id)
then it was not fetched from the database and therefore we have no original
entity data yet. All of the current entity data is stored as the original entity data.
{@link _entityChangeSets}
The changes detected on all properties of the entity are stored there.
A change is a tuple array where the first entry is the old value and the second
entry is the new value of the property. Changesets are used by persisters
to INSERT/UPDATE the persistent entity state.
{@link _entityUpdates}
If the entity is already fully MANAGED (has been fetched from the database before)
and any changes to its properties are detected, then a reference to the entity is stored
there to mark it for an update.
{@link _collectionDeletions}
If a PersistentCollection has been de-referenced in a fully MANAGED entity,
then this collection is marked for deletion.
|
#
|
public
|
computeChangeSets(): void
Computes all the changes that have been done to entities and collections
since the last commit and stores these changes…
Computes all the changes that have been done to entities and collections
since the last commit and stores these changes in the _entityChangeSet map
temporarily for access by the persisters, until the UoW commit is finished.
|
#
|
private
|
computeAssociationChanges(AssociationMapping $assoc, mixed $value): void
Computes the changes of an association.
Computes the changes of an association.
Parameters
| $assoc |
The association mapping.
|
| $value |
The value of the association.
|
Throws
|
#
|
private
|
persistNew<T is object>(ClassMetadata<T> $class, T $entity): void
|
#
|
private
|
hasMissingIdsWhichAreForeignKeys(ClassMetadata $class, mixed[] $idValue): bool
|
#
|
public
|
recomputeSingleEntityChangeSet<T is object>(ClassMetadata<T> $class, T $entity): void
INTERNAL:
Computes the changeset of an individual entity, independently of the
computeChangeSets() routine that is used…
INTERNAL:
Computes the changeset of an individual entity, independently of the
computeChangeSets() routine that is used at the beginning of a UnitOfWork#commit().
The passed entity must be a managed entity. If the entity already has a change set
because this method is invoked during a commit cycle then the change sets are added.
whereby changes detected in this method prevail.
Throws
|
#
|
private
|
executeInserts(): void
Executes entity insertions
Executes entity insertions
|
#
|
private
|
addToEntityIdentifiersAndEntityMap<T is object>(ClassMetadata<T> $class, int $oid, T $entity): void
|
#
|
private
|
executeUpdates(): void
Executes all entity updates
Executes all entity updates
|
#
|
private
|
executeDeletions(): void
Executes all entity deletions
Executes all entity deletions
|
#
|
private
|
computeInsertExecutionOrder(): list<object>
|
#
|
private
|
computeDeleteExecutionOrder(): list<object>
|
#
|
public
|
scheduleForInsert(object $entity): void
Schedules an entity for insertion into the database.
If the entity already has an identifier, it will be added to the…
Schedules an entity for insertion into the database.
If the entity already has an identifier, it will be added to the identity map.
Parameters
| $entity |
The entity to schedule for insertion.
|
Throws
|
#
|
public
|
isScheduledForInsert(object $entity): bool
Checks whether an entity is scheduled for insertion.
Checks whether an entity is scheduled for insertion.
|
#
|
public
|
scheduleForUpdate(object $entity): void
Schedules an entity for being updated.
Schedules an entity for being updated.
Parameters
| $entity |
The entity to schedule for being updated.
|
Throws
|
#
|
public
|
scheduleExtraUpdate(object $entity, array<string, array{mixed, mixed}> $changeset): void
INTERNAL:
Schedules an extra update that will be executed immediately after the
regular entity updates within the…
INTERNAL:
Schedules an extra update that will be executed immediately after the
regular entity updates within the currently running commit cycle.
Extra updates for entities are stored as (entity, changeset) tuples.
Parameters
| $entity |
The entity for which to schedule an extra update.
|
| $changeset |
The changeset of the entity (what to update).
|
|
#
|
public
|
isScheduledForUpdate(object $entity): bool
Checks whether an entity is registered as dirty in the unit of work.
Note: Is not very useful currently as dirty…
Checks whether an entity is registered as dirty in the unit of work.
Note: Is not very useful currently as dirty entities are only registered
at commit time.
|
#
|
public
|
isScheduledForDirtyCheck(object $entity): bool
Checks whether an entity is registered to be checked in the unit of work.
Checks whether an entity is registered to be checked in the unit of work.
|
#
|
public
|
scheduleForDelete(object $entity): void
INTERNAL:
Schedules an entity for deletion.
INTERNAL:
Schedules an entity for deletion.
|
#
|
public
|
isScheduledForDelete(object $entity): bool
Checks whether an entity is registered as removed/deleted with the unit
of work.
Checks whether an entity is registered as removed/deleted with the unit
of work.
|
#
|
public
|
isEntityScheduled(object $entity): bool
Checks whether an entity is scheduled for insertion, update or deletion.
Checks whether an entity is scheduled for insertion, update or deletion.
|
#
|
public
|
addToIdentityMap(object $entity): bool
INTERNAL:
Registers an entity in the identity map.
Note that entities in a hierarchy are registered with the class name…
INTERNAL:
Registers an entity in the identity map.
Note that entities in a hierarchy are registered with the class name of
the root entity.
Parameters
| $entity |
The entity to register.
|
Returns
TRUE if the registration was successful, FALSE if the identity of
the entity in question is already managed.
Throws
|
#
|
final
public
static
|
getIdHashByIdentifier(array<string|int, mixed> $identifier): string
Gets the id hash of an entity by its identifier.
Gets the id hash of an entity by its identifier.
Parameters
| $identifier |
The identifier of an entity
|
Returns
|
#
|
public
|
getIdHashByEntity(object $entity): string
Gets the id hash of an entity.
Gets the id hash of an entity.
Parameters
| $entity |
The entity managed by Unit Of Work
|
Returns
|
#
|
public
|
getEntityState(object $entity, self::STATE_*|null $assume = null): int
Gets the state of an entity with regard to the current unit of work.
Gets the state of an entity with regard to the current unit of work.
Returns
|
#
|
public
|
removeFromIdentityMap(object $entity): bool
INTERNAL:
Removes an entity from the identity map. This effectively detaches the
entity from the persistence management…
INTERNAL:
Removes an entity from the identity map. This effectively detaches the
entity from the persistence management of Doctrine.
Throws
|
#
|
public
|
getByIdHash(string $idHash, string $rootClassName): object
INTERNAL:
Gets an entity in the identity map by its identifier hash.
INTERNAL:
Gets an entity in the identity map by its identifier hash.
|
#
|
public
|
tryGetByIdHash(mixed $idHash, string $rootClassName): false|object
INTERNAL:
Tries to get an entity by its identifier hash. If no entity is found for
the given hash, FALSE is returned.
INTERNAL:
Tries to get an entity by its identifier hash. If no entity is found for
the given hash, FALSE is returned.
Parameters
| $idHash |
(must be possible to cast it to string)
|
Returns
The found entity or FALSE.
|
#
|
public
|
isInIdentityMap(object $entity): bool
Checks whether an entity is registered in the identity map of this UnitOfWork.
Checks whether an entity is registered in the identity map of this UnitOfWork.
|
#
|
public
|
containsIdHash(string $idHash, string $rootClassName): bool
INTERNAL:
Checks whether an identifier hash exists in the identity map.
INTERNAL:
Checks whether an identifier hash exists in the identity map.
|
#
|
public
|
persist(object $entity): void
Persists an entity as part of the current unit of work.
Persists an entity as part of the current unit of work.
Parameters
| $entity |
The entity to persist.
|
|
#
|
private
|
doPersist(object $entity, array<int, object> &$visited): void
Persists an entity as part of the current unit of work.
Persists an entity as part of the current unit of work.
This method is internally called during persist() cascades as it tracks
the already visited entities to prevent infinite recursions.
Parameters
| $entity |
The entity to persist.
|
| $visited |
The already visited entities.
|
Throws
|
#
|
public
|
remove(object $entity): void
Deletes an entity as part of the current unit of work.
Deletes an entity as part of the current unit of work.
Parameters
| $entity |
The entity to remove.
|
|
#
|
private
|
doRemove(object $entity, array<int, object> &$visited): void
Deletes an entity as part of the current unit of work.
Deletes an entity as part of the current unit of work.
This method is internally called during delete() cascades as it tracks
the already visited entities to prevent infinite recursions.
Parameters
| $entity |
The entity to delete.
|
| $visited |
The map of the already visited entities.
|
Throws
|
#
|
public
|
merge(object $entity): object
Merges the state of the given detached entity into this UnitOfWork.
Merges the state of the given detached entity into this UnitOfWork.
Deprecated
2.7 This method is being removed from the ORM and won't have any replacement
Returns
The managed copy of the entity.
Throws
|
#
|
private
|
doMerge(
object $entity,
array<int, object> &$visited,
$prevManagedCopy = null,
AssociationMapping|null $assoc = null,
): object
Executes a merge operation on an entity.
Executes a merge operation on an entity.
Returns
The managed copy of the entity.
Throws
|
#
|
private
|
ensureVersionMatch<T is object>(ClassMetadata<T> $class, T $entity, T $managedCopy): void
|
#
|
private
|
updateAssociationWithMergedEntity(
object $entity,
AssociationMapping $association,
$previousManagedCopy,
$managedCopy,
): void
Sets/adds associated managed copies into the previous entity's association field
Sets/adds associated managed copies into the previous entity's association field
|
#
|
public
|
detach(object $entity): void
Detaches an entity from the persistence management. It's persistence will
no longer be managed by Doctrine.
Detaches an entity from the persistence management. It's persistence will
no longer be managed by Doctrine.
Parameters
| $entity |
The entity to detach.
|
|
#
|
private
|
doDetach(object $entity, mixed[] &$visited, bool $noCascade = false): void
Executes a detach operation on the given entity.
Executes a detach operation on the given entity.
Parameters
| $noCascade |
if true, don't cascade detach operation.
|
|
#
|
public
|
refresh(object $entity): void
Refreshes the state of the given entity from the database, overwriting
any local, unpersisted changes.
Refreshes the state of the given entity from the database, overwriting
any local, unpersisted changes.
Parameters
| $entity |
The entity to refresh
|
Throws
|
#
|
private
|
doRefresh(object $entity, array<int, object> &$visited, LockMode::*|null $lockMode = null): void
Executes a refresh operation on an entity.
Executes a refresh operation on an entity.
Parameters
| $entity |
The entity to refresh.
|
| $visited |
The already visited entities during cascades.
|
Throws
|
#
|
private
|
cascadeRefresh(object $entity, array<int, object> &$visited, LockMode::*|null $lockMode = null): void
Cascades a refresh operation to associated entities.
Cascades a refresh operation to associated entities.
|
#
|
private
|
cascadeDetach(object $entity, array<int, object> &$visited): void
Cascades a detach operation to associated entities.
Cascades a detach operation to associated entities.
|
#
|
private
|
cascadeMerge(object $entity, object $managedCopy, array<int, object> &$visited): void
Cascades a merge operation to associated entities.
Cascades a merge operation to associated entities.
|
#
|
private
|
cascadePersist(object $entity, array<int, object> &$visited): void
Cascades the save operation to associated entities.
Cascades the save operation to associated entities.
|
#
|
private
|
cascadeRemove(object $entity, array<int, object> &$visited): void
Cascades the delete operation to associated entities.
Cascades the delete operation to associated entities.
|
#
|
public
|
lock(object $entity, LockMode::* $lockMode, int|DateTimeInterface|null $lockVersion = null): void
Acquire a lock on the given entity.
Acquire a lock on the given entity.
Throws
|
#
|
public
|
getCommitOrderCalculator(): CommitOrderCalculator
Gets the CommitOrderCalculator used by the UnitOfWork to order commits.
Gets the CommitOrderCalculator used by the UnitOfWork to order commits.
|
#
|
public
|
clear(string|null $entityName = null): void
Clears the UnitOfWork.
Parameters
| $entityName |
if given, only entities of this type will get detached.
|
Throws
|
#
|
public
|
scheduleOrphanRemoval(object $entity): void
INTERNAL:
Schedules an orphaned entity for removal. The remove() operation will be
invoked on that entity at the…
INTERNAL:
Schedules an orphaned entity for removal. The remove() operation will be
invoked on that entity at the beginning of the next commit of this
UnitOfWork.
|
#
|
public
|
cancelOrphanRemoval(object $entity): void
INTERNAL:
Cancels a previously scheduled orphan removal.
INTERNAL:
Cancels a previously scheduled orphan removal.
|
#
|
public
|
scheduleCollectionDeletion(PersistentCollection $coll): void
INTERNAL:
Schedules a complete collection for removal when this UnitOfWork commits.
INTERNAL:
Schedules a complete collection for removal when this UnitOfWork commits.
|
#
|
public
|
isCollectionScheduledForDeletion(PersistentCollection $coll): bool
|
#
|
private
|
newInstance(ClassMetadata $class): object
|
#
|
public
|
createEntity(class-string $className, mixed[] $data, array<string, mixed> &$hints = []): object
INTERNAL:
Creates an entity. Used for reconstitution of persistent entities.
INTERNAL:
Creates an entity. Used for reconstitution of persistent entities.
Internal note: Highly performance-sensitive method.
Parameters
| $data |
The data for the entity.
|
Returns
The managed entity instance.
|
#
|
public
|
triggerEagerLoads(): void
|
#
|
public
|
loadCollection(PersistentCollection $collection): void
Initializes (loads) an uninitialized persistent collection of an entity.
Initializes (loads) an uninitialized persistent collection of an entity.
Parameters
| $collection |
The collection to initialize.
|
|
#
|
public
|
getIdentityMap()
Gets the identity map of the UnitOfWork.
Gets the identity map of the UnitOfWork.
|
#
|
public
|
getOriginalEntityData(object $entity): mixed[]
Gets the original data of an entity. The original data is the data that was
present at the time the entity was…
Gets the original data of an entity. The original data is the data that was
present at the time the entity was reconstituted from the database.
|
#
|
public
|
setOriginalEntityData(object $entity, mixed[] $data): void
|
#
|
public
|
setOriginalEntityProperty(int $oid, string $property, mixed $value): void
INTERNAL:
Sets a property value of the original data array of an entity.
INTERNAL:
Sets a property value of the original data array of an entity.
|
#
|
public
|
getEntityIdentifier(object $entity): mixed[]
Gets the identifier of an entity.
The returned value is always an array of identifier values. If the entity
has a…
Gets the identifier of an entity.
The returned value is always an array of identifier values. If the entity
has a composite identifier then the identifier values are in the same
order as the identifier field names as returned by ClassMetadata#getIdentifierFieldNames().
Returns
|
#
|
public
|
getSingleIdentifierValue(object $entity): mixed
Processes an entity instance to extract their identifier values.
Processes an entity instance to extract their identifier values.
Parameters
| $entity |
The entity instance.
|
Returns
Throws
|
#
|
public
|
tryGetById(mixed $id, class-string $rootClassName): object|false
Tries to find an entity with the given identifier in the identity map of
this UnitOfWork.
Tries to find an entity with the given identifier in the identity map of
this UnitOfWork.
Parameters
| $id |
The entity identifier to look for.
|
Returns
Returns the entity with the specified identifier if it exists in
this UnitOfWork, FALSE otherwise.
|
#
|
public
|
scheduleForDirtyCheck(object $entity): void
Schedules an entity for dirty-checking at commit-time.
Schedules an entity for dirty-checking at commit-time.
Parameters
| $entity |
The entity to schedule for dirty-checking.
|
|
#
|
public
|
hasPendingInsertions(): bool
Checks whether the UnitOfWork has any pending insertions.
Checks whether the UnitOfWork has any pending insertions.
Returns
TRUE if this UnitOfWork has pending insertions, FALSE otherwise.
|
#
|
public
|
size(): int
Calculates the size of the UnitOfWork. The size of the UnitOfWork is the
number of entities in the identity map.
Calculates the size of the UnitOfWork. The size of the UnitOfWork is the
number of entities in the identity map.
|
#
|
public
|
getEntityPersister(class-string $entityName): EntityPersister
Gets the EntityPersister for an Entity.
Gets the EntityPersister for an Entity.
|
#
|
public
|
getCollectionPersister(AssociationMapping $association): CollectionPersister
Gets a collection persister for a collection-valued association.
Gets a collection persister for a collection-valued association.
|
#
|
public
|
registerManaged(object $entity, mixed[] $id, mixed[] $data): void
INTERNAL:
Registers an entity as managed.
INTERNAL:
Registers an entity as managed.
Parameters
| $entity |
The entity.
|
| $id |
The identifier values.
|
| $data |
The original entity data.
|
|
#
|
public
|
clearEntityChangeSet(int $oid): void
INTERNAL:
Clears the property changeset of the entity with the given OID.
INTERNAL:
Clears the property changeset of the entity with the given OID.
Parameters
|
#
|
public
|
propertyChanged(object $sender, string $propertyName, mixed $oldValue, mixed $newValue): void
Notifies this UnitOfWork of a property change in an entity.
Notifies this UnitOfWork of a property change in an entity.
Parameters
| $sender |
The entity that owns the property.
|
| $propertyName |
The name of the property that changed.
|
| $oldValue |
The old value of the property.
|
| $newValue |
The new value of the property.
|
Implements
|
#
|
public
|
getScheduledEntityInsertions()
Gets the currently scheduled entity insertions in this UnitOfWork.
Gets the currently scheduled entity insertions in this UnitOfWork.
|
#
|
public
|
getScheduledEntityUpdates()
Gets the currently scheduled entity updates in this UnitOfWork.
Gets the currently scheduled entity updates in this UnitOfWork.
|
#
|
public
|
getScheduledEntityDeletions()
Gets the currently scheduled entity deletions in this UnitOfWork.
Gets the currently scheduled entity deletions in this UnitOfWork.
|
#
|
public
|
getScheduledCollectionDeletions()
Gets the currently scheduled complete collection deletions
Gets the currently scheduled complete collection deletions
|
#
|
public
|
getScheduledCollectionUpdates()
Gets the currently scheduled collection inserts, updates and deletes.
Gets the currently scheduled collection inserts, updates and deletes.
|
#
|
public
|
initializeObject(object $obj): void
Helper method to initialize a lazy loading proxy or persistent collection.
Helper method to initialize a lazy loading proxy or persistent collection.
|
#
|
public
|
isUninitializedObject(mixed $obj): bool
Tests if a value is an uninitialized entity.
Tests if a value is an uninitialized entity.
|
#
|
private
static
|
objToStr(object $obj): string
Helper method to show an object as string.
Helper method to show an object as string.
|
#
|
public
|
markReadOnly(object $object): void
Marks an entity as read-only so that it will not be considered for updates during UnitOfWork#commit().
Marks an entity as read-only so that it will not be considered for updates during UnitOfWork#commit().
This operation cannot be undone as some parts of the UnitOfWork now keep gathering information
on this object that might be necessary to perform a correct update.
Throws
|
#
|
public
|
isReadOnly(object $object): bool
Is this entity read only?
Is this entity read only?
Throws
|
#
|
private
|
afterTransactionComplete(): void
Perform whatever processing is encapsulated here after completion of the transaction.
Perform whatever processing is encapsulated here after completion of the transaction.
|
#
|
private
|
afterTransactionRolledBack(): void
Perform whatever processing is encapsulated here after completion of the rolled-back.
Perform whatever processing is encapsulated here after completion of the rolled-back.
|
#
|
private
|
performCallbackOnCachedPersister(callable $callback): void
Performs an action after the transaction.
Performs an action after the transaction.
|
#
|
private
|
dispatchOnFlushEvent(): void
|
#
|
private
|
dispatchPostFlushEvent(): void
|
#
|
private
|
isIdentifierEquals(object $entity1, object $entity2): bool
Verifies if two given entities actually are the same based on identifier comparison
Verifies if two given entities actually are the same based on identifier comparison
|
#
|
private
|
assertThatThereAreNoUnintentionallyNonPersistedAssociations(): void
|
#
|
private
|
mergeEntityStateIntoManagedCopy(object $entity, object $managedCopy): void
|
#
|
private
|
clearIdentityMapForEntityName(string $entityName): void
|
#
|
private
|
clearEntityInsertionsForEntityName(string $entityName): void
|
#
|
private
|
convertSingleFieldIdentifierToPHPValue(ClassMetadata $class, mixed $identifierValue): mixed
Returns
the identifier after type conversion
Throws
|
#
|
private
|
normalizeIdentifier(ClassMetadata $targetClass, mixed[] $flatIdentifier): array<string, mixed>
Given a flat identifier, this method will produce another flat identifier, but with all
association fields that are…
Given a flat identifier, this method will produce another flat identifier, but with all
association fields that are mapped as identifiers replaced by entity references, recursively.
|
#
|
final
public
|
assignPostInsertId(object $entity, mixed $generatedId): void
Assign a post-insert generated ID to an entity
Assign a post-insert generated ID to an entity
This is used by EntityPersisters after they inserted entities into the database.
It will place the assigned ID values in the entity's fields and start tracking
the entity in the identity map.
|
#
|