$bookingCreateDto->currentStep) { $this->addFlash('error', 'Bitte erst die vorherigen Schritte abschließen.'); return $this->redirectToCurrentStep($bookingCreateDto); } return null; } /** * Redirects to the current step based on the DTO's currentStep. */ private function redirectToCurrentStep(BookingDto $bookingCreateDto): RedirectResponse { $route = match ($bookingCreateDto->currentStep) { 2 => 'app_booking_create_step_2', 3 => 'app_booking_create_step_3', 4 => 'app_booking_create_step_4', default => 'app_booking_create_step_1', }; return $this->redirectToRoute($route); } /** * Returns the total number of participants based on room selections. */ private function getParticipantsCount(BookingDto $bookingCreateDto): int { return $this ->bookingService ->getParticipantsCount($bookingCreateDto->roomSelections, $bookingCreateDto->travel); } /** * Prepares template variables for the booking summary sidebar. * * @return array Array containing all variables needed for the summary partial */ private function getSummaryVariables(BookingDto $bookingCreateDto): array { $participantsCount = $this->getParticipantsCount($bookingCreateDto); $summary = $this->bookingService->getRoomSummaryAndParticipantCount($bookingCreateDto); $roomAssignmentCounts = $bookingCreateDto->getRoomAssignmentCounts(); $availableRooms = $bookingCreateDto->travel->getAvailableRooms(); $groupedSelectedRooms = $this->bookingService->groupRoomSelectionsByType($bookingCreateDto->getSelectedRooms(), $availableRooms); return [ 'participantsCount' => $participantsCount, 'pricingData' => $summary['pricing'], 'assignmentCounts' => $roomAssignmentCounts, 'groupedSelectedRooms' => $groupedSelectedRooms, ]; } /** * Handles API errors by logging, adding flash message, and rendering the form. */ private function handleApiError( string $logMessage, array $context, string $flashMessage, BookingDto $bookingCreateDto, FormInterface $form, ): Response { $this->logger->error($logMessage, $context); $this->addFlash('error', $flashMessage); return $this->renderStepForm($bookingCreateDto, $form); } }