public function fetch(Contract $aggregateType, $aggregateId) { $eventEnvelopes = []; $result = $this->findByAggregateTypeAndId($aggregateType, $aggregateId); while ($record = $result->fetch()) { $event = json_decode($record['event'], true); $metadata = $record['metadata_type'] ? json_decode($record['metadata'], true) : null; $eventType = $this->eventContractResolver->resolveFromContractName($record['event_type']); $metadataType = $record['metadata_type'] ? $this->metadataContractResolver->resolveFromContractName($record['metadata_type']) : null; $metadata = $metadata ? $this->metadataSerializer->deserialize($metadataType, $metadata) : null; $eventEnvelopes[] = new EventEnvelope($eventType, $record['event_id'], $this->eventSerializer->deserialize($eventType, $event), $record['aggregate_version'], new DateTimeImmutable($record['when']), $metadataType, $metadata); } return $eventEnvelopes; }
private function deserializeCommittedEvent($row) { return new CommittedEvent(CommitId::fromString($row['commit_id']), DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $row['utc_committed_time']), new Contract($row['aggregate_root_type'], str_replace('.', '\\', $row['aggregate_root_type'])), $row['aggregate_root_id'], (int) $row['aggregate_root_version'], new EventEnvelope($this->eventContractResolver->resolveFromContractName($row['event_type']), $row['event_id'], $this->eventSerializer->deserialize($this->eventContractResolver->resolveFromContractName($row['event_type']), json_decode($row['event'], true)), (int) $row['event_version'], DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $row['when']))); }