45 lines
1.4 KiB
PHP
45 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Controller\Booking\Create;
|
|
|
|
use App\Service\BookingService;
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
use Symfony\Component\Routing\Attribute\Route;
|
|
|
|
/**
|
|
* Handles the success page after completing the booking creation flow.
|
|
*/
|
|
class SuccessController extends AbstractController
|
|
{
|
|
public function __construct(
|
|
private readonly BookingService $bookingService,
|
|
) {
|
|
}
|
|
|
|
#[Route('/bookings/create/success', name: 'app_booking_create_success')]
|
|
public function success(Request $request): Response
|
|
{
|
|
$flashBag = $request->getSession()->getFlashBag();
|
|
$bookingNumber = $flashBag->get('booking_number')[0] ?? null;
|
|
$bookingTotal = $flashBag->get('booking_total')[0] ?? null;
|
|
$travelName = $flashBag->get('booking_travel_name')[0] ?? null;
|
|
$returnUrl = $this->bookingService->getReturnUrl($request);
|
|
|
|
// Redirect to return URL if no booking number (direct access or refresh)
|
|
if (null === $bookingNumber) {
|
|
return $this->redirect($returnUrl);
|
|
}
|
|
|
|
return $this->render('booking/create/success.html.twig', [
|
|
'bookingNumber' => $bookingNumber,
|
|
'bookingTotal' => $bookingTotal,
|
|
'travelName' => $travelName,
|
|
'returnUrl' => $returnUrl,
|
|
]);
|
|
}
|
|
}
|