예제 #1
0
 /**
  * @param Event $event
  */
 public function on(Event $event)
 {
     try {
         $document = $this->readStorage->find($event->getIdentity()->getValue());
     } catch (\Apha\StateStore\Storage\DocumentNotFoundException $e) {
         $document = new DemoDocument($event->getIdentity()->getValue(), $event->getVersion());
     }
     $document->apply($event);
     $this->readStorage->upsert($event->getIdentity()->getValue(), $document);
     echo "Stored state version: {$event->getVersion()}\n";
 }
예제 #2
0
 /**
  * @param Event $event
  */
 public function on(Event $event)
 {
     $eventName = $event->getEventName();
     $this->logger->info('Handle event', ['command' => $eventName, 'handler' => get_class($this)]);
     try {
         $document = $this->storage->find($event->getIdentity()->getValue());
         $document->apply($event);
     } catch (\Apha\StateStore\Storage\DocumentNotFoundException $e) {
         $document = new UserDocument($event->getIdentity()->getValue(), $event->getVersion());
     }
     $this->storage->upsert($event->getIdentity()->getValue(), $document);
     var_dump($this->storage->find($event->getIdentity()->getValue()));
 }
예제 #3
0
 /**
  * @Apha\EventHandler()
  * @param DeadlineExpired $event
  */
 public function onDeadlineExpired(DeadlineExpired $event)
 {
     $this->stateStorage->delete($event->getIdentity()->getValue());
 }