feat: prevent booking flow without available rooms

This commit is contained in:
Björn Fromme
2026-03-16 11:59:10 +01:00
parent 82b47e314b
commit 7ce3bc18b2
5 changed files with 71 additions and 7 deletions
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace App\Controller\Booking;
use App\Exception\NoRoomsAvailableException;
use App\Service\BookingService;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
@@ -31,7 +32,13 @@ class CreateStep3Controller extends AbstractController
#[Route('/bookings/create/confirm', name: 'app_booking_create_step_3')]
public function confirm(Request $request): Response
{
$bookingCreateDto = $this->bookingCreateService->getOrCreateBookingCreateDto($request);
try {
$bookingCreateDto = $this->bookingCreateService->getOrCreateBookingCreateDto($request);
} catch (NoRoomsAvailableException $e) {
$this->addFlash('error', 'Leider sind für diese Reise aktuell keine Zimmer verfügbar.');
// TODO: Redirect to travel listing or hotel details page
throw $this->createNotFoundException('No rooms available for this travel.');
}
// Validate step access
$this->validateStepAccess($bookingCreateDto, 3);