wip: insurance booking

This commit is contained in:
Björn Fromme
2026-03-16 11:59:10 +01:00
parent 29bdf794f3
commit e6eebc00a3
4 changed files with 76 additions and 40 deletions
@@ -91,10 +91,18 @@ class ParticipantFieldHandlerRegistry
/**
* Processes all participant fields from submitted form data using registered handlers.
*
* This is the main entry point for field processing. It iterates through all
* participants in the submitted data and applies the appropriate handlers in
* dependency order. Each handler determines whether it should process the
* participant's data and updates the booking DTO accordingly.
* This is the main entry point for field processing. It processes handlers in dependency
* order, applying each handler to ALL participants before moving to the next handler.
* This ensures that cross-participant logic (like family booking detection) has access
* to complete data from all participants.
*
* Processing order: handler-first, then participants
* - Process handler A for all participants
* - Process handler B for all participants
* - etc.
*
* This is critical for handlers that depend on booking-level state (like insurance
* family detection which needs all participants' ages to be processed first).
*
* @param array<string, mixed> $submittedData The submitted form data containing participants array
* @param BookingDtoInterface $bookingDto The booking DTO to update with processed field values (create or edit)
@@ -109,16 +117,17 @@ class ParticipantFieldHandlerRegistry
// Get handlers sorted by dependency order (uses cache if available)
$sortedHandlerNames = $this->getSortedHandlers();
// Process each participant's data
foreach ($submittedData['participants'] as $participantIndex => $participantData) {
// Skip invalid participant data
if (false === is_array($participantData)) {
continue;
}
// Process each handler across all participants before moving to the next handler
// This ensures booking-level state (like family booking detection) is accurate
foreach ($sortedHandlerNames as $handlerName) {
$handler = $this->handlers[$handlerName];
// Apply each handler in dependency order
foreach ($sortedHandlerNames as $handlerName) {
$handler = $this->handlers[$handlerName];
// Apply this handler to all participants
foreach ($submittedData['participants'] as $participantIndex => $participantData) {
// Skip invalid participant data
if (false === is_array($participantData)) {
continue;
}
// Let each handler decide if it should process this participant's data
if ($handler->shouldProcess($participantData, (int) $participantIndex)) {