Example #1
0
 /**
  * @param Event $event
  */
 public function on(Event $event)
 {
     $eventName = $event->getEventName();
     $this->logger->info('Handling event', ['event' => $eventName, 'handler' => get_class($this)]);
     $events = $this->storage->find($event->getIdentity()->getValue());
     var_dump($events);
 }
Example #2
0
 /**
  * @param Event $event
  * @throws UnsupportedEventException
  */
 protected function apply(Event $event)
 {
     $applyMethod = 'apply' . $event->getEventName();
     if (!method_exists($this, $applyMethod)) {
         throw new UnsupportedEventException($event, $this);
     }
     static::$applyMethod($event);
 }
Example #3
0
 /**
  * @param Event $event
  * @throws \InvalidArgumentException
  */
 private function applyByInflection(Event $event)
 {
     $eventApplyMethod = 'apply' . $event->getEventName();
     if (!method_exists($this, $eventApplyMethod)) {
         $eventClassName = get_class($event);
         throw new \InvalidArgumentException("Unable to apply event '{$eventClassName}'.");
     }
     $this->{$eventApplyMethod}($event);
 }
Example #4
0
 /**
  * @param Event $event
  * @throws \InvalidArgumentException
  */
 private function handleEventByInflection(Event $event)
 {
     $eventHandleMethod = 'on' . $event->getEventName();
     if (!method_exists($this, $eventHandleMethod)) {
         $eventClassName = get_class($event);
         throw new \InvalidArgumentException("Unable to handle event '{$eventClassName}'.");
     }
     $this->{$eventHandleMethod}($event);
 }
Example #5
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()));
 }
Example #6
0
 /**
  * @param Event $event
  */
 public function on(Event $event)
 {
     $eventName = $event->getEventName();
     $this->logger->info('Handle event', ['event' => $eventName, 'handler' => get_class($this)]);
 }
 /**
  * @param Event $event
  * @param AggregateRoot $aggregateRoot
  */
 public function __construct(Event $event, AggregateRoot $aggregateRoot)
 {
     parent::__construct(sprintf(static::$messageTemplate, $event->getEventName(), get_class($aggregateRoot)));
 }
Example #8
0
 /**
  * @param Identity $aggregateId
  * @param string $aggregateType
  * @param Event $event
  */
 private function saveEvent(Identity $aggregateId, string $aggregateType, Event $event)
 {
     $eventData = EventDescriptor::record($aggregateId->getValue(), $aggregateType, $event->getEventName(), $this->serializer->serialize($event), $event->getVersion());
     $this->storage->append($eventData);
 }