chore: adopt namespace pattern for accommodation booking controllers

This commit is contained in:
Björn Fromme
2026-08-19 17:07:57 +02:00
parent e105c611be
commit d5f9f4ef10
25 changed files with 137 additions and 138 deletions
@@ -2,15 +2,15 @@
declare(strict_types=1);
namespace App\Controller\Groups;
namespace App\Controller\Groups\Booking;
use App\Exception\AccommodationSessionNotFoundException;
use App\Form\Model\AccommodationBookingDto;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController as SymfonyAbstractController;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
abstract class AbstractAccommodationController extends AbstractController
abstract class AbstractController extends SymfonyAbstractController
{
protected function validateStepAccess(AccommodationBookingDto $dto, int $expectedStep): ?RedirectResponse
{
@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace App\Controller\Groups;
namespace App\Controller\Groups\Booking;
use App\Htmx\HxTrait;
use App\Model\AccommodationBookingQueryParams;
@@ -14,7 +14,7 @@ use Symfony\Component\HttpFoundation\Session\FlashBagAwareSessionInterface;
use Symfony\Component\HttpKernel\Attribute\MapQueryString;
use Symfony\Component\Routing\Attribute\Route;
class IndexController extends AbstractAccommodationController
class IndexController extends AbstractController
{
use HxTrait;
@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace App\Controller\Groups;
namespace App\Controller\Groups\Booking;
use App\BpnConnect\ContingentsClient;
use App\BpnConnect\Exception\BpnConnectException;
@@ -24,7 +24,7 @@ use Symfony\Component\Routing\Attribute\Route;
use Symfony\Contracts\Cache\CacheInterface;
use Symfony\Contracts\Cache\ItemInterface;
class Step1Controller extends AbstractAccommodationController
class Step1Controller extends AbstractController
{
use HxTrait;
@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace App\Controller\Groups;
namespace App\Controller\Groups\Booking;
use App\Entity\Groups\AdditionalService;
use App\Entity\Groups\BoardService;
@@ -19,7 +19,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
class Step2Controller extends AbstractAccommodationController
class Step2Controller extends AbstractController
{
use HxTrait;
@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace App\Controller\Groups;
namespace App\Controller\Groups\Booking;
use App\Entity\Groups\Accommodation;
use App\Exception\AccommodationSessionNotFoundException;
@@ -15,7 +15,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
class Step3Controller extends AbstractAccommodationController
class Step3Controller extends AbstractController
{
public function __construct(
private readonly AccommodationBookingService $bookingService,
@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace App\Controller\Groups;
namespace App\Controller\Groups\Booking;
use App\Entity\Groups\Accommodation;
use App\Entity\Groups\AdditionalService;
@@ -20,7 +20,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
class Step4Controller extends AbstractAccommodationController
class Step4Controller extends AbstractController
{
use HxTrait;
@@ -80,7 +80,7 @@ class Step4Controller extends AbstractAccommodationController
$inquiryForm = $this->createForm(AccommodationInquiryConfirmationType::class);
return $this->render('groups/booking/_step4_inquiry_confirmation_modal.html.twig', [
return $this->render('groups/booking/modal_inquiry_confirmation.html.twig', [
'inquiryForm' => $inquiryForm,
]);
}
@@ -107,7 +107,7 @@ class Step4Controller extends AbstractAccommodationController
return $this->htmxRedirect($request, $this->generateUrl('app_groups_booking_success'));
}
return $this->render('groups/booking/_step4_booking_confirmation_modal.html.twig', [
return $this->render('groups/booking/modal_booking_confirmation.html.twig', [
'confirmationForm' => $confirmationForm,
]);
}
@@ -2,7 +2,7 @@
declare(strict_types=1);
namespace App\Controller\Groups;
namespace App\Controller\Groups\Offer;
use App\Entity\Groups\AccommodationBooking;
use App\Form\Model\OfferAcceptDto;
@@ -20,7 +20,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
class OfferController extends AbstractController
class IndexController extends AbstractController
{
use HxTrait;
@@ -38,35 +38,35 @@ class OfferController extends AbstractController
* authorizes the session for this booking, and redirects to the plain
* (session-gated) offer page nothing downstream needs the signature again.
*/
#[Route(path: '/groups/booking/offer/{uuid}', name: 'app_groups_booking_offer', methods: ['GET'])]
#[Route(path: '/groups/booking/offer/{uuid}', name: 'app_groups_offer', methods: ['GET'])]
public function access(string $uuid, Request $request): Response
{
$booking = $this->bookingRepository->findOneBy(['uuid' => $uuid]);
if (null === $booking || false === $this->linkSigner->isValidLinkRequest($request, $booking)) {
return $this->render('groups/booking/offer_unavailable.html.twig');
return $this->render('groups/offer/unavailable.html.twig');
}
if (!$this->isCustomerVisible($booking)) {
return $this->render('groups/booking/offer_unavailable.html.twig');
return $this->render('groups/offer/unavailable.html.twig');
}
$this->linkSigner->authorizeSession($request, $booking);
return new RedirectResponse($this->generateUrl('app_groups_booking_offer_view', ['uuid' => $uuid]));
return new RedirectResponse($this->generateUrl('app_groups_offer_view', ['uuid' => $uuid]));
}
#[Route(path: '/groups/booking/offer/{uuid}/view', name: 'app_groups_booking_offer_view', methods: ['GET'])]
#[Route(path: '/groups/booking/offer/{uuid}/view', name: 'app_groups_offer_view', methods: ['GET'])]
public function view(string $uuid, Request $request): Response
{
$booking = $this->bookingRepository->findOneBy(['uuid' => $uuid]);
if (null === $booking || false === $this->linkSigner->isSessionAuthorized($request, $booking)) {
return $this->render('groups/booking/offer_unavailable.html.twig');
return $this->render('groups/offer/unavailable.html.twig');
}
if (!$this->isCustomerVisible($booking)) {
return $this->render('groups/booking/offer_unavailable.html.twig');
return $this->render('groups/offer/unavailable.html.twig');
}
$accommodation = $booking->getAccommodation() ?? throw $this->createNotFoundException('Booking has no accommodation.');
@@ -78,14 +78,14 @@ class OfferController extends AbstractController
priceBreakdown: $priceBreakdown,
);
return $this->render('groups/booking/offer.html.twig', [
return $this->render('groups/offer/view.html.twig', [
'booking' => $booking,
'priceBreakdown' => $priceBreakdown,
'ctx' => $ctx,
]);
}
#[Route(path: '/groups/booking/offer/{uuid}/confirm', name: 'app_groups_booking_offer_confirm', methods: ['GET', 'POST'])]
#[Route(path: '/groups/booking/offer/{uuid}/confirm', name: 'app_groups_offer_confirm', methods: ['GET', 'POST'])]
public function confirm(string $uuid, Request $request): Response
{
$booking = $this->bookingRepository->findOneBy(['uuid' => $uuid]);
@@ -115,7 +115,7 @@ class OfferController extends AbstractController
return $this->redirectToOfferPage($request, $uuid);
}
return $this->render('groups/booking/_offer_accept_confirmation_modal.html.twig', [
return $this->render('groups/offer/modal_accept_confirmation.html.twig', [
'booking' => $booking,
'confirmationForm' => $confirmationForm,
]);
@@ -138,7 +138,7 @@ class OfferController extends AbstractController
*/
private function redirectToOfferPage(Request $request, string $uuid): Response
{
$url = $this->generateUrl('app_groups_booking_offer_view', ['uuid' => $uuid]);
$url = $this->generateUrl('app_groups_offer_view', ['uuid' => $uuid]);
return $this->htmxRedirect($request, $url);
}
@@ -34,7 +34,7 @@ class AccommodationBookingLinkSigner
}
$url = $this->urlGenerator->generate(
'app_groups_booking_offer',
'app_groups_offer',
['uuid' => $booking->getUuid(), self::TIMESTAMP_PARAM => $issuedAt->getTimestamp()],
UrlGeneratorInterface::ABSOLUTE_URL,
);