/** * @param \Apha\Message\Event $event * @return void */ public function apply(\Apha\Message\Event $event) { $this->version = $event->getVersion(); if ($event instanceof DemonstratedEvent) { $this->demonstrated = true; } }
/** * @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"; }
/** * @param Event $event * @return void */ public function apply(Event $event) { $this->version = $event->getVersion(); }