wip: skipass-duration based rentals filtering

This commit is contained in:
Björn Fromme
2026-03-16 11:59:10 +01:00
parent ed7c889c4f
commit 1e48e107fc
8 changed files with 288 additions and 17 deletions
@@ -14,10 +14,10 @@ use App\Form\Service\Abstract\AbstractParticipantFieldHandler;
*
* This handler manages rental equipment selections for participants in the booking
* creation process. It processes the rentals field from form submissions,
* filters out age-inappropriate options, and updates the participant DTO with only
* valid selections.
* filters out age-inappropriate options and duration-inappropriate options, and
* updates the participant DTO with only valid selections.
*
* Dependencies: dateOfBirth (must be processed first for age evaluation)
* Dependencies: dateOfBirth (for age evaluation) and skiPass (for duration filtering)
*/
class ParticipantRentalsFieldHandler extends AbstractParticipantFieldHandler
{
@@ -26,6 +26,19 @@ class ParticipantRentalsFieldHandler extends AbstractParticipantFieldHandler
return 'rentals';
}
/**
* Returns the field dependencies for proper processing order.
*
* This handler depends on both dateOfBirth (for age evaluation) and skiPass
* (for duration filtering and field visibility logic).
*
* @return string[] Array containing 'dateOfBirth' and 'skiPass' dependencies
*/
public function getDependencies(): array
{
return ['dateOfBirth', 'skiPass'];
}
/**
* Determines if this handler should process the field based on submitted data.
*
@@ -51,6 +64,14 @@ class ParticipantRentalsFieldHandler extends AbstractParticipantFieldHandler
return;
}
// Check if rentals should be available based on skipass selection
if (null === $participant->skiPass) {
// No skipass selected = clear all rental selections
$participant->rentals = [];
return;
}
$selectedRentals = $this->getFieldValue($submittedData, $this->getFieldName()) ?? [];
$availableRentals = $bookingDto->travel->getAdditionalServicesBySubTypes(Constants::TOKEN_RENTALS, true, true);