Prooph\EventStore\EventStore::beginTransaction PHP Метод

beginTransaction() публичный Метод

Begin transaction
public beginTransaction ( )
    public function beginTransaction()
    {
        if (!$this->inTransaction && $this->adapter instanceof CanHandleTransaction) {
            $this->adapter->beginTransaction();
        }
        $this->inTransaction = true;
        $event = $this->actionEventEmitter->getNewActionEvent(__FUNCTION__, $this, ['inTransaction' => true]);
        $this->getActionEventEmitter()->dispatch($event);
    }

Usage Example

 /**
  * @test
  */
 public function it_translates_aggregate_back_and_forth()
 {
     $this->eventStore->beginTransaction();
     $user = User::nameNew('John Doe');
     $this->repository->addAggregateRoot($user);
     $this->eventStore->commit();
     $this->eventStore->beginTransaction();
     //Simulate a normal program flow by fetching the AR before modifying it
     $user = $this->repository->getAggregateRoot($user->id());
     $user->changeName('Max Mustermann');
     $this->eventStore->commit();
     $this->resetRepository();
     $loadedUser = $this->repository->getAggregateRoot($user->id());
     $this->assertEquals('Max Mustermann', $loadedUser->name());
     return $loadedUser;
 }
All Usage Examples Of Prooph\EventStore\EventStore::beginTransaction