isCustomerAccessible() || null === $booking->getAccessLinkIssuedAt()) { return $this->redirectToRoute('app_admin_accommodationbooking_show', ['id' => $booking->getId()]); } if ($request->isMethod(Request::METHOD_POST)) { if (!$this->isCsrfTokenValid('send_accommodation_booking_access_link_'.$booking->getId(), $request->request->getString('_token'))) { throw $this->createAccessDeniedException('Invalid CSRF token.'); } // Older bookings can still be missing their contact data. Sending would be // silently skipped further down, so say so instead of reporting success. if (null === $booking->getEmail() || '' === trim($booking->getEmail())) { $this->addFlash('error', 'Für diese Buchung ist keine E-Mail-Adresse hinterlegt. Bitte ergänze sie, um den Zugangslink zu senden.'); return new HxRedirectResponse($this->generateUrl('app_admin_accommodationbooking_edit', ['id' => $booking->getId()])); } $this->bookingService->sendAccessLink($booking); $this->addFlash('success', 'Ein neuer Zugangslink wurde dem Kunden per E-Mail zugestellt.'); $this->logger->info('Sent accommodation booking access link', [ 'id' => $booking->getId(), ]); return new HxRedirectResponse($this->generateUrl('app_admin_accommodationbooking_show', ['id' => $booking->getId()])); } return $this->render('admin/accommodation_booking/modal_send_access_link.html.twig', [ 'booking' => $booking, 'csrf_token_id' => 'send_accommodation_booking_access_link_'.$booking->getId(), ]); } }