Пример #1
0
 public function testConstructWithMappingAddsToMap()
 {
     $list = [FooEvent::class, BarEvent::class];
     $map = new EventClassMap($list);
     self::assertEquals(FooEvent::class, $map->getClassByEventName('FooEvent'));
     self::assertEquals(BarEvent::class, $map->getClassByEventName('BarEvent'));
 }
Пример #2
0
 /**
  * @param Uuid $aggregateId
  * @return Events
  * @throws AggregateNotFoundException
  */
 public function getEventsForAggregate(Uuid $aggregateId)
 {
     if (!$this->storage->contains($aggregateId->getValue())) {
         throw new AggregateNotFoundException($aggregateId);
     }
     $eventsData = $this->storage->find($aggregateId->getValue());
     $events = array_map(function (EventDescriptor $eventData) {
         return $this->serializer->deserialize($eventData->getPayload(), $this->eventMap->getClassByEventName($eventData->getEvent()), 'json');
     }, $eventsData);
     return new Events($events);
 }