Exemplo n.º 1
0
 protected function setUp()
 {
     $this->eventStore = new EventStore(new InMemoryEventStorage(), new NullBus(), new InMemoryIdentityMap());
     $this->repository = new CustomerRepository($this->eventStore);
     $this->commandBus = new SymfonyEventDispatcherBus(new EventDispatcher());
     $this->commandBus->subscribe(new CreateCustomerCommandHandler($this->repository));
     $this->commandBus->subscribe(new ChangeCustomerNameCommandHandler($this->repository));
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function commit()
 {
     if ($this->eventStorage instanceof TransactionalInterface) {
         $this->eventStorage->beginTransaction();
     }
     foreach ($this->identityMap as $eventStream) {
         $this->eventStorage->saveUncommittedEventStream($eventStream);
         $this->eventBus->publish(new MessageStream($eventStream));
     }
     if ($this->eventStorage instanceof TransactionalInterface) {
         $this->eventStorage->commit();
     }
     $this->eventBus->commit();
     $this->identityMap->clear();
 }