Example #1
0
 /**
  * {@inheritdoc}
  */
 public function get(Identifies $aggregateId)
 {
     $lookupKey = $this->createLookupKey($aggregateId);
     if (!isset($this->map[$lookupKey])) {
         throw AggregateIdNotFound::create($aggregateId);
     }
     return $this->map[$lookupKey];
 }
 /**
  * {@inheritdoc}
  */
 public function read(Identifies $aggregateId)
 {
     $envelopes = [];
     foreach ($this->store as $envelope) {
         if ($envelope->aggregateId()->equals($aggregateId)) {
             $envelopes[] = $envelope;
         }
     }
     if (!$envelopes) {
         throw AggregateIdNotFound::create($aggregateId);
     }
     return new EventStream($aggregateId, $envelopes);
 }
 /**
  * {@inheritdoc}
  */
 public function read(Identifies $aggregateId)
 {
     $statement = $this->prepareSelectStatement();
     $statement->bindValue('aggregate_id', (string) $aggregateId, Type::GUID);
     $statement->execute();
     $envelopes = [];
     while ($row = $statement->fetch(PDO::FETCH_ASSOC)) {
         $eventName = $row['event_name'];
         $eventClass = $this->eventNameResolver->resolveEventClass($eventName);
         $event = $this->serializer->deserialize($row['event_payload'], $eventClass);
         $metadata = $this->serializer->deserialize($row['metadata'], 'SimpleES\\EventSourcing\\Metadata\\Metadata');
         $envelopes[] = EventEnvelope::fromStore(EventId::fromString($row['event_id']), $eventName, $event, $aggregateId, (int) $row['aggregate_version'], Timestamp::fromString($row['took_place_at']), $metadata);
     }
     if (!$envelopes) {
         throw AggregateIdNotFound::create($aggregateId);
     }
     return new EventStream($aggregateId, $envelopes);
 }