$submittedData The submitted participant form data * @param string $mode The booking mode (BookingDto::MODE_CREATE or MODE_EDIT) * @param int $participantIndex The index of the participant being processed * * @return bool Always returns true for parking selection fields */ public function shouldProcess(array $submittedData, string $mode, int $participantIndex): bool { return true; // Always process for state changes } public function processField(array $submittedData, BookingDto $bookingDto, int $participantIndex): void { $participant = $this->getParticipant($bookingDto, $participantIndex); if (null === $participant) { return; } // Check if parking is applicable (outbound transportation is PKW) if (!$this->isParkingApplicable($participant)) { $participant->parking = false; // Clear parking when outbound is not PKW $participant->parkingService = null; // Clear parking service object return; } $parkingSelected = $this->getFieldValue($submittedData, $this->getFieldName()); $isParkingSelected = (bool) $parkingSelected; // Store boolean value for backward compatibility $participant->parking = $isParkingSelected; // Store parking service object for pricing calculation if (true === $isParkingSelected) { $participant->parkingService = $this->findParkingService($bookingDto); } else { $participant->parkingService = null; } } /** * Checks if parking is applicable based on outbound transportation selection. * * Parking is only needed when arriving by car at the destination. * * @param object $participant The participant DTO * * @return bool True if parking is applicable, false otherwise */ private function isParkingApplicable(object $participant): bool { return DirectionMapper::SUBTYPE_CAR_API === $participant->transportationOutbound?->subType; } /** * Finds the parking service from available services. * * Gets the first (and typically only) parking service for pricing calculation. * Returns null if no parking services are available. * * @param BookingDto $bookingDto The booking DTO containing travel data * * @return Service|null The parking service object, or null if not found */ private function findParkingService(BookingDto $bookingDto): ?Service { $parkingServices = $bookingDto->travel->getAdditionalServicesBySubTypes(Constants::TOKEN_PARKING, true); if (empty($parkingServices)) { return null; } // Return the first parking service (there's typically only one parking type) return reset($parkingServices); } }