feat: use query parameters for booking urls
This commit is contained in:
@@ -10,11 +10,13 @@ use App\Exception\HotelNotInTravelException;
|
||||
use App\Exception\NoRoomsAvailableException;
|
||||
use App\Exception\TravelNotFoundException;
|
||||
use App\Htmx\HxTrait;
|
||||
use App\Model\BookingQueryParams;
|
||||
use App\Service\BookingService;
|
||||
use App\Service\BookingSummaryDataService;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Attribute\MapQueryString;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
/**
|
||||
@@ -48,21 +50,27 @@ class IndexController extends AbstractController
|
||||
* defaults to agency code '0001'.
|
||||
*/
|
||||
#[Route(
|
||||
path: '/bookings/create/{dateId}/{hotelId}',
|
||||
path: '/bookings/create',
|
||||
name: 'app_booking_create_init',
|
||||
requirements: ['dateId' => '\d+', 'hotelId' => '\d+']
|
||||
)]
|
||||
public function init(Request $request, int $dateId, int $hotelId): Response
|
||||
public function init(Request $request, #[MapQueryString] ?BookingQueryParams $params): Response
|
||||
{
|
||||
if (null === $params) {
|
||||
throw $this->createNotFoundException('Invalid booking parameters provided');
|
||||
}
|
||||
|
||||
$dateId = $params->dateId;
|
||||
$hotelId = $params->hotelId;
|
||||
|
||||
try {
|
||||
// Clear any existing booking session to ensure fresh start
|
||||
$this->bookingService->clearBookingSession($request);
|
||||
|
||||
// Determine agency ID from optional query parameter
|
||||
$agencyId = $this->resolveAgencyId($request->query->get('agency'));
|
||||
$agencyId = $this->resolveAgencyId($params->agency);
|
||||
|
||||
// Store optional return URL in session (defaults to main EP site)
|
||||
$this->bookingService->storeReturnUrl($request, $request->query->get('r'));
|
||||
$this->bookingService->storeReturnUrl($request, $params->returnUrl);
|
||||
|
||||
// Create fresh booking session with the provided parameters
|
||||
$bookingDto = $this->bookingService->startFreshBooking($request, $dateId, $hotelId, $agencyId);
|
||||
|
||||
Reference in New Issue
Block a user