Skip to content

Commit

Permalink
pr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Koen Eelen committed Nov 15, 2024
1 parent 6b3f36a commit 41520ae
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions src/BackwardsCompatiblePayloadSerializerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,24 @@ function (array $serializedObject) use ($contactPointUpdatedEvent) {
);
}

self::fillDescriptions($payloadManipulatingSerializer);
$updateDescriptionEvents = [
EventDescriptionUpdated::class,
PlaceDescriptionUpdated::class,
];

foreach ($updateDescriptionEvents as $descriptionUpdatedEvent) {
$payloadManipulatingSerializer->manipulateEventsOfClass(
$descriptionUpdatedEvent,
function (array $serializedObject) use ($descriptionUpdatedEvent) {
$serializedObject = self::fillDescriptions($serializedObject);

if ($descriptionUpdatedEvent === EventDescriptionUpdated::class) {
return self::replaceEventIdWithItemId($serializedObject);
}
return self::replacePlaceIdWithItemId($serializedObject);
}
);
}

/**
* Roles
Expand Down Expand Up @@ -537,27 +553,11 @@ private static function addDefaultMainLanguage(array $serializedObject): array
return $serializedObject;
}

private static function fillDescriptions(PayloadManipulatingSerializer $payloadManipulatingSerializer): void
private static function fillDescriptions(array $serializedObject): array
{
$updateDescriptionEvents = [
EventDescriptionUpdated::class,
PlaceDescriptionUpdated::class,
];

foreach ($updateDescriptionEvents as $descriptionUpdatedEvent) {
$payloadManipulatingSerializer->manipulateEventsOfClass(
$descriptionUpdatedEvent,
function (array $serializedObject) use ($descriptionUpdatedEvent) {
if (empty(trim($serializedObject['payload']['description']))) {
$serializedObject['payload']['description'] = '---';
}

if ($descriptionUpdatedEvent === EventDescriptionUpdated::class) {
return self::replaceEventIdWithItemId($serializedObject);
}
return self::replacePlaceIdWithItemId($serializedObject);
}
);
if (empty(trim($serializedObject['payload']['description']))) {
$serializedObject['payload']['description'] = '---';
}
return $serializedObject;
}
}

0 comments on commit 41520ae

Please sign in to comment.