bookingRepository->findOneBy(['uuid' => $uuid]); if (null === $booking || false === $this->linkSigner->isSessionAuthorized($request, $booking)) { return $this->redirectToOfferPage($request, $uuid); } // Offen is the one status that means an offer is out and awaiting acceptance, so it // is the whole guard — mirroring acceptBooking(), which no-ops on anything else. if (!$booking->isOpen()) { return $this->redirectToOfferPage($request, $uuid); } // Checked for POST as well, so the modal cannot be submitted around the contact page. if (!$this->bookingService->hasCompleteContactData($booking)) { return $this->htmxRedirect($request, $this->generateUrl('app_groups_offer_contact', ['uuid' => $uuid])); } $dto = new OfferAcceptDto(remarks: $booking->getRemarks()); $confirmationForm = $this->createForm(OfferAcceptConfirmationType::class, $dto, [ 'terms_url' => $this->termsUrlProvider->forAccommodation($booking->getAccommodation()), ]); $confirmationForm->handleRequest($request); if ($confirmationForm->isSubmitted() && $confirmationForm->isValid()) { // The textarea is prefilled, so the submitted value is the complete remark — // an emptied field arrives as null and must clear the stored one, not keep it. $this->bookingService->acceptBooking($booking, $dto->remarks ?? ''); $this->addFlash('success', 'Deine Buchung ist bei uns eingegangen. Sobald sie geprüft ist, erhältst du eine Bestätigung per E-Mail.'); return $this->redirectToOfferPage($request, $uuid); } return $this->render('groups/offer/modal_accept_confirmation.html.twig', [ 'booking' => $booking, 'confirmationForm' => $confirmationForm, ]); } }