feat: add typed dto for cms data

This commit is contained in:
Björn Fromme
2026-04-12 18:17:54 +02:00
parent 6ab34fa87c
commit 16cab4b768
13 changed files with 78 additions and 34 deletions
@@ -138,6 +138,8 @@ class Step2ParticipantController extends AbstractController
'form' => $form->createView(),
'participantIndex' => $index,
'bookingCreateContext' => $bookingCreateContext,
'bookingDto' => $bookingCreateContext->bookingDto,
'summaryData' => $bookingCreateContext->summaryData,
'refreshRouteName' => 'app_booking_create_step_2_participant_refresh',
]);
}
@@ -207,6 +209,8 @@ class Step2ParticipantController extends AbstractController
'form' => $form->createView(),
'participantIndex' => $index,
'bookingCreateContext' => $bookingCreateContext,
'bookingDto' => $bookingCreateContext->bookingDto,
'summaryData' => $bookingCreateContext->summaryData,
'refreshRouteName' => $refreshRouteName,
]
);
@@ -102,6 +102,9 @@ class ParticipantController extends AbstractController
'form' => $form->createView(),
'participantIndex' => $index,
'bookingEditContext' => $context,
'bookingDto' => $context->bookingDto,
'summaryData' => $context->summaryData,
'mutableData' => $context->mutableData,
'refreshRouteName' => 'app_booking_edit_participant_refresh',
'refreshRouteParams' => ['id' => $id, 'index' => $index],
'cancelRouteName' => 'app_booking_edit',
@@ -158,6 +161,9 @@ class ParticipantController extends AbstractController
'form' => $form->createView(),
'participantIndex' => $index,
'bookingEditContext' => $context,
'bookingDto' => $context->bookingDto,
'summaryData' => $context->summaryData,
'mutableData' => $context->mutableData,
'refreshRouteName' => 'app_booking_edit_participant_refresh',
'refreshRouteParams' => ['id' => $id, 'index' => $index],
'cancelRouteName' => 'app_booking_edit',
+3 -1
View File
@@ -4,6 +4,8 @@ declare(strict_types=1);
namespace App\Form\Model;
use App\Model\BookingSummaryCmsHotelDto;
/**
* DTO containing all booking summary data for sidebar display.
*/
@@ -17,7 +19,7 @@ class BookingSummaryDto
public readonly int $participantCount,
public readonly BookingSummaryPricingDto $pricing,
public readonly BookingSummaryVoucherDto $vouchers,
public readonly ?array $cmsData,
public readonly ?BookingSummaryCmsHotelDto $cmsData,
) {
}
}
+21
View File
@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
namespace App\Model;
/**
* Typed hotel CMS payload for the booking summary.
*/
final readonly class BookingSummaryCmsHotelDto
{
/**
* @param array<string, mixed>|null $images
*/
public function __construct(
public ?string $name,
public ?string $address,
public ?array $images,
) {
}
}
+7 -9
View File
@@ -12,6 +12,7 @@ use App\Form\Model\BookingDto;
use App\Form\Model\BookingSummaryDto;
use App\Form\Model\BookingSummaryPricingDto;
use App\Form\Model\BookingSummaryVoucherDto;
use App\Model\BookingSummaryCmsHotelDto;
use Psr\Log\LoggerInterface;
use Symfony\Contracts\Cache\CacheInterface;
use Symfony\Contracts\Cache\ItemInterface;
@@ -153,7 +154,7 @@ class BookingSummaryDataService
* Data is cached for 1 hour. This method can be called early in the booking
* flow to warm the cache.
*/
public function getCmsDataForProduct(?string $productCode, ?string $hotelCode): ?array
public function getCmsDataForProduct(?string $productCode, ?string $hotelCode): ?BookingSummaryCmsHotelDto
{
if (null === $hotelCode) {
return null;
@@ -171,14 +172,11 @@ class BookingSummaryDataService
// Fetch CMS images (nice to have)
$images = $this->cmsDataService->getProductImages($productCode, $hotelCode);
// Return combined data structure compatible with templates
return [
'hotel' => [
'name' => $baseHotel?->name,
'address' => $this->formatHotelAddress($baseHotel),
'images' => $images,
],
];
return new BookingSummaryCmsHotelDto(
name: $baseHotel?->name,
address: $this->formatHotelAddress($baseHotel),
images: $images,
);
});
} catch (\Throwable $e) {
$this->logger->error('Failed to fetch hotel display data', [