wip: skipass-duration based rentals filtering
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user