*/ #[Assert\Valid] public array $participants = []; public function __construct(public Booking $booking, public Travel $travel) { } public static function fromBooking(Booking $booking, Travel $travel): static { $instance = new static($booking, $travel); $instance->booking = $booking; $instance->travel = $travel; foreach ($booking->participants as $index => $participant) { /** @var PersonalData $participant */ $participantData = ParticipantDto::fromPersonalData($participant); $participantData->index = $index; $participantData->courses = $booking ->getAdditionalServicesForParticipantByGroup($index, Constants::TOKEN_COURSES); // Skipass is single selection - use dedicated method $participantData->skiPass = $booking->getSkiPassForParticipant($index); $participantData->additionalServices = $booking ->getAdditionalServicesForParticipantByGroup($index, Constants::TOKEN_ADDITIONAL); $participantData->board = $booking ->getAdditionalServicesForParticipantByGroup($index, Constants::TOKEN_BOARD); $participantData->rentals = $booking ->getAdditionalServicesForParticipantByGroup($index, Constants::TOKEN_RENTALS); // Transportation services using improved direction mapping // Direction mapping handles BusProNet's inconsistent codes (H <=> HIN, R <=> RUECK) $outboundTransportation = $booking ->getTransportationServiceForParticipantAndDirection($index, DirectionMapper::OUTBOUND_BOOKING); $inboundTransportation = $booking ->getTransportationServiceForParticipantAndDirection($index, DirectionMapper::INBOUND_BOOKING); // Set new improved property names $participantData->transportationOutbound = $outboundTransportation; $participantData->transportationInbound = $inboundTransportation; // Pickup handling (currently only supports outbound pickup) $pickup = $booking->getPickupForParticipant($index); $participantData->pickup = $pickup; // Insurance - get insurance for participant $insurance = $booking->getInsuranceForParticipant($index); $participantData->insurance = $insurance; // Room assignment - extract from booking room mappings $room = $booking->getRoomForParticipant($index); $participantData->assignedRoomId = $room?->id; $instance->participants[$index] = $participantData; } return $instance; } public function isCanceled(): bool { return 'S' === $this->booking->status; } public function isOption(): bool { return 'O' === $this->booking->status; } public function getParticipants(): array { return $this->participants; } public function hasParticipant(int $index): bool { return isset($this->participants[$index]); } public function getParticipant(int $index): ?ParticipantDto { return $this->participants[$index] ?? null; } /** * Gets all selected rooms for the booking (edit context). * * @return array always returns an empty array for edit DTOs unless implemented */ public function getSelectedRooms(): array { return []; } }