-
-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
Description
For some projections, it is convenient to use the doctrine entity manager instead of low-level inserts or updates (using dbal connection). But in this case, without calling the flush method, the projection can not be restored after reset, but calling flush explicitly duplicates the transaction block during the synchronous operation of the projection using command handler, especially since there can be several synchronous projections for one event.
Example
/**
* @throws OptimisticLockException
* @throws ORMException
*/
#[EventHandler]
public function onCardWasClosed(CardWasClosed $event): void
{
/** @var Card $card */
$card = $this->entityManager->find(Card::class, (string) $event->id);
$card->markAsClosed($event->closedAt());
$this->entityManager->flush(); // redundant during command handler
}Metadata
Metadata
Assignees
Labels
No labels