From 42103d1ccae5e435362b30dde506337b5de97663 Mon Sep 17 00:00:00 2001 From: Bastian Waidelich Date: Sun, 21 Jan 2024 12:55:49 +0100 Subject: [PATCH] TASK: Update neos/eventstore packages to 1.0 Updates `neos/eventstore` and `neos/eventstore-doctrineadapter` packages to their first final release and adjusts code accordingly. Furthermore this incorporates the following changes: * Add `CheckpointStorageInterface` and its implementation `DbalCheckpointStorage` (aka `DoctrineCheckpointStorage`) from `neos/eventstore-doctrineadapter` (see https://github.com/neos/eventstore-doctrineadapter/pull/13) * Add `CatchUp` from `neos/eventstore` (see https://github.com/neos/eventstore/pull/19) --- src/Event/ValueObject/ExportedEvent.php | 2 +- src/Processors/EventStoreImportProcessor.php | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Event/ValueObject/ExportedEvent.php b/src/Event/ValueObject/ExportedEvent.php index ac765f5..8e9c7d9 100644 --- a/src/Event/ValueObject/ExportedEvent.php +++ b/src/Event/ValueObject/ExportedEvent.php @@ -23,7 +23,7 @@ public static function fromRawEvent(Event $event): self $event->id->value, $event->type->value, \json_decode($event->data->value, true), - $event->metadata->value, + $event->metadata?->value ?? [], ); } diff --git a/src/Processors/EventStoreImportProcessor.php b/src/Processors/EventStoreImportProcessor.php index 9afa36d..23606b1 100644 --- a/src/Processors/EventStoreImportProcessor.php +++ b/src/Processors/EventStoreImportProcessor.php @@ -159,19 +159,18 @@ public function run(): ProcessorResult */ private function normalizeEvent(EventInterface|DecoratedEvent $event): Event { - if ($event instanceof DecoratedEvent) { - $eventId = $event->eventId; - $eventMetadata = $event->eventMetadata; - $event = $event->innerEvent; - } else { - $eventId = EventId::create(); - $eventMetadata = EventMetadata::none(); - } + $eventId = $event instanceof DecoratedEvent ? $event->eventId : EventId::create(); + $eventMetadata = $event instanceof DecoratedEvent ? $event->eventMetadata : null; + $causationId = $event instanceof DecoratedEvent ? $event->causationId : null; + $correlationId = $event instanceof DecoratedEvent ? $event->correlationId : null; + $event = $event instanceof DecoratedEvent ? $event->innerEvent : $event; return new Event( $eventId, $this->eventNormalizer->getEventType($event), $this->eventNormalizer->getEventData($event), $eventMetadata, + $causationId, + $correlationId, ); }