wip: form refactoring

This commit is contained in:
Björn Fromme
2026-03-16 11:59:09 +01:00
parent 65a33922cf
commit d719b17aec
13 changed files with 158 additions and 100 deletions
@@ -23,8 +23,7 @@ class CreateStep1Controller extends AbstractController
public function __construct(
private readonly BookingService $bookingService,
)
{
) {
}
/**
@@ -34,6 +33,10 @@ class CreateStep1Controller extends AbstractController
public function index(Request $request): Response
{
$bookingCreateDto = $this->bookingService->getOrCreateBookingCreateDto($request);
// Capture the current room selection state before form processing
$oldRoomSelectionSnapshot = $this->bookingService->createRoomSelectionSnapshot($bookingCreateDto);
$summary = $this->bookingService->getRoomSummaryAndParticipantCount($bookingCreateDto);
// Validate step access - allow step 1 or redirect to current step
@@ -46,6 +49,9 @@ class CreateStep1Controller extends AbstractController
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
if ($this->bookingService->hasRoomSelectionChanged($oldRoomSelectionSnapshot, $bookingCreateDto)) {
$this->bookingService->resetParticipantAssignments($bookingCreateDto);
}
$bookingCreateDto->currentStep = 2;
$this->bookingService->saveBookingCreateDto($request, $bookingCreateDto);
@@ -80,8 +86,6 @@ class CreateStep1Controller extends AbstractController
]);
$form->handleRequest($request);
$this->bookingService->saveBookingCreateDto($request, $bookingCreateDto);
$summary = $this->bookingService->getRoomSummaryAndParticipantCount($bookingCreateDto);
$availableRooms = $bookingCreateDto->travel->getAvailableRooms();
$groupedSelectedRooms = $this->bookingService->groupRoomSelectionsByType($summary['selectedRooms'], $availableRooms);
@@ -27,8 +27,7 @@ class CreateStep2Controller extends AbstractController
public function __construct(
private readonly BookingService $bookingService,
)
{
) {
}
/**