wip: backport booking create flow form handling to edit flow

This commit is contained in:
Björn Fromme
2026-03-16 11:59:10 +01:00
parent e330626b03
commit d70a27f2fd
5 changed files with 143 additions and 32 deletions
@@ -69,6 +69,7 @@ class BookingDataProcessor
* Resets all existing participant-to-service mappings to start with a clean slate.
*
* This ensures that service assignments are rebuilt from scratch based on current form selections.
* Includes resetting room mappings to allow room reassignments during edit.
*
* @param object $bookingData The booking data object containing services to reset
*/
@@ -79,6 +80,7 @@ class BookingDataProcessor
...$bookingData->transportationServices,
...$bookingData->pickupsOutbound,
...$bookingData->pickupsInbound,
...$bookingData->rooms,
];
foreach ($servicesToReset as $service) {
@@ -90,7 +92,7 @@ class BookingDataProcessor
* Processes all services for a single participant.
*
* This orchestrator method handles the complete service assignment workflow for one participant,
* including additional services, transportation services, and pickup locations.
* including additional services, transportation services, pickup locations, and room assignments.
*
* @param object $participant The participant data from the form
* @param object $bookingData The booking data object to update
@@ -105,6 +107,7 @@ class BookingDataProcessor
$this->processAdditionalServices($participant, $bookingData, $travelData);
$this->processTransportationServices($participant, $bookingData, $travelData);
$this->processPickupLocations($participant, $bookingData);
$this->processRoomAssignment($participant, $bookingData);
}
/**
@@ -190,6 +193,31 @@ class BookingDataProcessor
}
}
/**
* Processes room assignment for a participant.
*
* Maps the participant to their assigned room. Allows room reassignment during
* booking edits while maintaining the constraint that participants can only be
* assigned to room types that have already been booked.
*
* @param object $participant The participant data from the form
* @param object $bookingData The booking data object to update
*/
private function processRoomAssignment(object $participant, object $bookingData): void
{
if (null === $participant->assignedRoomId) {
return;
}
// Find the room in the existing booking by ID
foreach ($bookingData->rooms as $room) {
if ($room->id === $participant->assignedRoomId) {
$room->mapping[] = $participant->index;
break;
}
}
}
/**
* Removes services and pickups with no participant mappings.
*