Пример #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);
 }
Пример #2
0
 /**
  * @param Identity $aggregateId
  * @return Events
  * @throws AggregateNotFoundException
  */
 public function getEventsForAggregate(Identity $aggregateId) : Events
 {
     if (!$this->storage->contains($aggregateId->getValue())) {
         throw new AggregateNotFoundException($aggregateId);
     }
     $eventData = $this->storage->find($aggregateId->getValue());
     $events = array_map(function (EventDescriptor $data) : Event {
         return $this->serializer->deserialize($data->getPayload(), $this->eventMap->getClassByEventName($data->getEvent()));
     }, $eventData);
     return new Events($events);
 }