public function testCanNotifyTransactionCommitPreparationToListeners() { $unitOfWork = $this->unitOfWorkMock(); $this->listener1->expects($this->once())->method('onPrepareTransactionCommit')->with($this->identicalTo($unitOfWork)); $this->listener2->expects($this->once())->method('onPrepareTransactionCommit')->with($this->identicalTo($unitOfWork)); $this->listeners->onPrepareTransactionCommit($unitOfWork); }
private function commitTransaction() { if ($this->isTransactional()) { $this->listeners->onPrepareTransactionCommit($this); $this->transactionManager->commitTransaction(); } }
public function commit() { if (!$this->hasStarted()) { throw new \Exception('The unit of work has not been started.'); } try { $this->listeners->onPrepareCommit($this, $this->registeredAggregates->all(), $this->stagingEvents->all()); $this->registeredAggregates->saveAggregateRoots(); $this->stagingEvents->publishEvents(); if ($this->isTransactional()) { $this->listeners->onPrepareTransactionCommit($this); $this->transactionManager->commitTransaction(); } $this->listeners->afterCommit($this); } catch (\Exception $exception) { $this->rollback($exception); throw $exception; } finally { $this->stop(); $this->listeners->onCleanup($this); } }