Provide access to original destination.one data within PSR-14 event

There is already an event in place that allows to modify the imported
data.
The original incoming data is now exposed by that event.

Relates: #10629
This commit is contained in:
Daniel Siepmann 2023-08-14 14:33:12 +02:00
parent 27ee70d0cf
commit e2adee20bc
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
2 changed files with 26 additions and 2 deletions

View file

@ -284,7 +284,8 @@ class DestinationDataImportService
$this->eventDispatcher->dispatch(new EventImportEvent(
$existingEvent,
$this->tmpCurrentEvent
$this->tmpCurrentEvent,
$event
));
// Update and persist

View file

@ -37,21 +37,44 @@ final class EventImportEvent
*/
private $eventToImport;
/**
* @var array
*/
private $eventData;
public function __construct(
Event $existingEvent,
Event $eventToImport
Event $eventToImport,
array $eventData
) {
$this->existingEvent = $existingEvent;
$this->eventToImport = $eventToImport;
$this->eventData = $eventData;
}
/**
* The existing event, or newly created, prior applying modifications.
* Can be used to compare existing data with new data for import.
*/
public function getBaseEvent(): Event
{
return clone $this->existingEvent;
}
/**
* The object that will finally be imported.
* Modifications to this object will result in modifications of imported data.
*/
public function getEventToImport(): Event
{
return $this->eventToImport;
}
/**
* The original data as received from API.
*/
public function getEventData(): array
{
return $this->eventData;
}
}