feat: rename BookingSessionStore to BookingSessionManager

This commit is contained in:
Björn Fromme
2026-04-16 13:34:54 +02:00
parent b68c4ff9b4
commit c0cc183c59
19 changed files with 59 additions and 57 deletions
@@ -12,7 +12,7 @@ use App\Exception\TravelNotFoundException;
use App\Htmx\HxTrait;
use App\Model\BookingQueryParams;
use App\Service\BookingConfigurator;
use App\Service\BookingSessionStore;
use App\Service\BookingSessionManager;
use App\Service\BookingSummaryAssembler;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
@@ -33,7 +33,7 @@ class IndexController extends AbstractController
public function __construct(
private readonly BookingConfigurator $bookingService,
private readonly BookingSessionStore $bookingSessionService,
private readonly BookingSessionManager $bookingSessionService,
private readonly AgencyLoader $agencyLoader,
private readonly BookingSummaryAssembler $summaryDataService,
) {
@@ -9,9 +9,9 @@ use App\Controller\Booking\Traits\BookingExceptionHandlerTrait;
use App\Form\BookingCreateStep1Type;
use App\Form\Model\BookingDto;
use App\Htmx\HxTrait;
use App\Service\BookingCreateContextFactory;
use App\Service\BookingConfigurator;
use App\Service\BookingSessionStore;
use App\Service\BookingCreateContextFactory;
use App\Service\BookingSessionManager;
use App\Service\RoomPricingCalculator;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
@@ -32,7 +32,7 @@ class Step1Controller extends AbstractController
public function __construct(
private readonly BookingConfigurator $bookingService,
private readonly BookingSessionStore $bookingSessionService,
private readonly BookingSessionManager $bookingSessionService,
private readonly BookingCreateContextFactory $createContextFactory,
) {
}
@@ -5,15 +5,15 @@ declare(strict_types=1);
namespace App\Controller\Booking\Create;
use App\BusProNet\Model\Travel;
use App\Entity\User;
use App\Controller\Booking\Traits\BookingCreateTrait;
use App\Controller\Booking\Traits\BookingExceptionHandlerTrait;
use App\Entity\User;
use App\Form\BookingCreateStep2Type;
use App\Form\Model\BookingDto;
use App\Form\Model\ParticipantDto;
use App\Service\BookingCreateContextFactory;
use App\Service\BookingConfigurator;
use App\Service\BookingSessionStore;
use App\Service\BookingCreateContextFactory;
use App\Service\BookingSessionManager;
use App\Service\ParticipantDataPrefiller;
use App\Service\RoomAssigner;
use App\Service\TravelDataProvider;
@@ -35,7 +35,7 @@ class Step2Controller extends AbstractController
public function __construct(
private readonly BookingConfigurator $bookingService,
private readonly BookingSessionStore $bookingSessionService,
private readonly BookingSessionManager $bookingSessionService,
private readonly BookingCreateContextFactory $createContextFactory,
private readonly TravelDataProvider $travelDataService,
private readonly RoomAssigner $roomAssignmentService,
@@ -7,13 +7,13 @@ namespace App\Controller\Booking\Create;
use App\Form\BookingParticipantType;
use App\Form\Model\BookingDto;
use App\Htmx\HxTrait;
use App\Service\BookingCreateContextFactory;
use App\Service\BookingConfigurator;
use App\Service\BookingSessionStore;
use App\Service\ParticipantFormSupport;
use App\Service\BookingCreateContextFactory;
use App\Service\BookingSessionManager;
use App\Service\ParticipantDataPrefiller;
use App\Service\TravelDataProvider;
use App\Service\ParticipantFormSupport;
use App\Service\RoomPricingCalculator;
use App\Service\TravelDataProvider;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
@@ -29,7 +29,7 @@ class Step2ParticipantController extends AbstractController
public function __construct(
private readonly BookingConfigurator $bookingService,
private readonly BookingSessionStore $bookingSessionService,
private readonly BookingSessionManager $bookingSessionService,
private readonly BookingCreateContextFactory $createContextFactory,
private readonly TravelDataProvider $travelDataService,
private readonly ParticipantDataPrefiller $prepopulationService,
@@ -13,11 +13,11 @@ use App\Controller\Booking\Traits\BookingExceptionHandlerTrait;
use App\Form\BookingCreateStep3Type;
use App\Form\Model\BookingDto;
use App\Htmx\HxTrait;
use App\Service\BookingConfigurator;
use App\Service\BookingCreateContextFactory;
use App\Service\BookingPriceCalculator;
use App\Service\BookingPriceMismatchAnalyzer;
use App\Service\BookingConfigurator;
use App\Service\BookingSessionStore;
use App\Service\BookingSessionManager;
use App\Service\RoomPricingCalculator;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@@ -37,7 +37,7 @@ class Step3Controller extends AbstractController
public function __construct(
private readonly BookingConfigurator $bookingService,
private readonly BookingSessionStore $bookingSessionService,
private readonly BookingSessionManager $bookingSessionService,
private readonly BookingCreateContextFactory $createContextFactory,
private readonly BookingPriceCalculator $priceCalculator,
private readonly BookingPriceMismatchAnalyzer $priceMismatchDiagnostics,
@@ -9,14 +9,14 @@ use App\BusProNet\Exception\TimeoutException;
use App\BusProNet\Model\Notification;
use App\Controller\Booking\Traits\BookingCreateTrait;
use App\Controller\Booking\Traits\BookingExceptionHandlerTrait;
use App\Entity\User;
use App\Exception\NewsletterProviderException;
use App\Form\BookingCreateStep4Type;
use App\Form\Model\BookingDto;
use App\Htmx\HxTrait;
use App\Entity\User;
use App\Service\BookingCreateContextFactory;
use App\Service\BookingConfigurator;
use App\Service\BookingSessionStore;
use App\Service\BookingCreateContextFactory;
use App\Service\BookingSessionManager;
use App\Service\MailjetApiClient;
use App\Service\NewsletterManager;
use Psr\Log\LoggerInterface;
@@ -38,7 +38,7 @@ class Step4Controller extends AbstractController
public function __construct(
private readonly BookingConfigurator $bookingService,
private readonly BookingSessionStore $bookingSessionService,
private readonly BookingSessionManager $bookingSessionService,
private readonly BookingCreateContextFactory $createContextFactory,
private readonly ApiClient $apiClient,
private readonly CacheInterface $cache,
@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace App\Controller\Booking\Create;
use App\Service\BookingSessionStore;
use App\Service\BookingSessionManager;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@@ -16,7 +16,7 @@ use Symfony\Component\Routing\Attribute\Route;
class SuccessController extends AbstractController
{
public function __construct(
private readonly BookingSessionStore $bookingSessionService,
private readonly BookingSessionManager $bookingSessionService,
) {
}
@@ -11,12 +11,12 @@ use App\Exception\TravelNotFoundException;
use App\Form\BookingEditType;
use App\Form\Model\BookingDto;
use App\Htmx\HxTrait;
use App\Service\BookingChangeTracker;
use App\Service\BookingEditContextFactory;
use App\Service\BookingEditDataLoader;
use App\Service\BookingEditDraftManager;
use App\Service\BookingEditContextFactory;
use App\Service\BookingChangeTracker;
use App\Service\BookingEditSubmitter;
use App\Service\BookingSessionStore;
use App\Service\BookingSessionManager;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@@ -40,7 +40,7 @@ class IndexController extends AbstractController
public function __construct(
private readonly BookingEditDataLoader $dataLoader,
private readonly BookingEditDraftManager $draftService,
private readonly BookingSessionStore $bookingSessionService,
private readonly BookingSessionManager $bookingSessionService,
private readonly BookingChangeTracker $fingerprintService,
private readonly BookingEditContextFactory $editContextFactory,
private readonly BookingEditSubmitter $submitService,
@@ -10,10 +10,10 @@ use App\Entity\User;
use App\Form\BookingParticipantType;
use App\Form\Model\BookingDto;
use App\Htmx\HxTrait;
use App\Service\BookingEditDataLoader;
use App\Service\BookingEditContextFactory;
use App\Service\BookingEditDataLoader;
use App\Service\BookingEditDraftManager;
use App\Service\BookingSessionStore;
use App\Service\BookingSessionManager;
use App\Service\ParticipantFormSupport;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
@@ -32,7 +32,7 @@ class ParticipantController extends AbstractController
private readonly BookingEditDataLoader $dataLoader,
private readonly BookingEditDraftManager $draftService,
private readonly BookingEditContextFactory $editContextFactory,
private readonly BookingSessionStore $bookingSessionService,
private readonly BookingSessionManager $bookingSessionService,
private readonly ParticipantFormSupport $participantFormSupportService,
) {
}
@@ -10,7 +10,7 @@ use App\Exception\HotelNotInTravelException;
use App\Exception\NoRoomsAvailableException;
use App\Exception\TravelNotFoundException;
use App\Form\Model\BookingDto;
use App\Service\BookingSessionStore;
use App\Service\BookingSessionManager;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@@ -29,7 +29,7 @@ trait BookingExceptionHandlerTrait
* Handles all booking-related exceptions and provides appropriate user feedback
* by redirecting to the error page with flash messages.
*/
protected function getOrCreateBookingCreateDto(BookingSessionStore $bookingSessionService, Request $request): BookingDto|RedirectResponse
protected function getOrCreateBookingCreateDto(BookingSessionManager $bookingSessionService, Request $request): BookingDto|RedirectResponse
{
try {
return $bookingSessionService->getOrCreateBookingCreateDto($request);
@@ -62,7 +62,7 @@ trait BookingExceptionHandlerTrait
* Returns empty 400 responses for HTMX requests when exceptions occur,
* allowing the frontend to handle errors appropriately.
*/
protected function getOrCreateBookingCreateDtoForHtmx(BookingSessionStore $bookingSessionService, Request $request): mixed
protected function getOrCreateBookingCreateDtoForHtmx(BookingSessionManager $bookingSessionService, Request $request): mixed
{
try {
return $bookingSessionService->getOrCreateBookingCreateDto($request);
+4 -3
View File
@@ -2,7 +2,8 @@
namespace App\Controller;
use App\Service\BookingSessionStore;
use App\Form\Model\BookingDto;
use App\Service\BookingSessionManager;
use App\Service\BookingSummaryAssembler;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
@@ -18,11 +19,11 @@ class SecurityController extends AbstractController
public function login(
AuthenticationUtils $authenticationUtils,
Request $request,
BookingSessionStore $bookingSessionService,
BookingSessionManager $bookingSessionService,
BookingSummaryAssembler $summaryDataService,
): Response {
// Check if this is a booking flow (BookingDto exists in session)
$bookingDto = $bookingSessionService->getBookingDto($request, BookingSessionStore::BOOKING_CREATE_KEY);
$bookingDto = $bookingSessionService->getBookingDto($request, BookingDto::MODE_CREATE);
$isBookingFlow = null !== $bookingDto;
// If authenticated and in booking flow, proceed to Step 1
+1 -1
View File
@@ -22,7 +22,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class BookingConfigurator
{
public function __construct(
private readonly BookingSessionStore $bookingSessionService,
private readonly BookingSessionManager $bookingSessionService,
private readonly TravelDataProvider $travelDataService,
private readonly ParticipantEligibilityChecker $participantEligibilityService,
private readonly BookingStatusRuleRegistry $bookingStatusRuleRegistry,
+1 -1
View File
@@ -32,7 +32,7 @@ class BookingEditDataLoader
public function __construct(
private readonly ApiClient $apiClient,
private readonly BookingDataProcessor $bookingDataProcessor,
private readonly BookingSessionStore $bookingSessionService,
private readonly BookingSessionManager $bookingSessionService,
private readonly BookingChangeTracker $fingerprintService,
private readonly TravelDataProvider $travelDataService,
private readonly BookingEditDraftManager $draftService,
+2 -2
View File
@@ -11,8 +11,8 @@ use App\BusProNet\Model\Notification;
use App\Entity\User;
use App\Form\Model\BookingDto;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
/**
@@ -26,7 +26,7 @@ class BookingEditSubmitter
private readonly BookingEditDraftManager $draftService,
private readonly TravelDataProvider $travelDataService,
private readonly BookingEditSubmitGuard $submitGuard,
private readonly BookingSessionStore $bookingSessionService,
private readonly BookingSessionManager $bookingSessionService,
private readonly UrlGeneratorInterface $urlGenerator,
private readonly LoggerInterface $logger,
) {
@@ -15,7 +15,7 @@ use Symfony\Component\HttpFoundation\Request;
* orchestration and pricing logic. It handles DTO persistence, baseline
* room snapshots, and return URL storage for the booking create/edit flows.
*/
class BookingSessionStore
class BookingSessionManager
{
public const BOOKING_CREATE_KEY = 'booking_create';
public const BOOKING_CREATE_BASELINE_KEY = 'booking_create_baseline_snapshot';
@@ -12,7 +12,7 @@ use App\BusProNet\XmlLoader\AgencyLoader;
use App\Form\Model\BookingDto;
use App\Form\Model\ParticipantDto;
use App\Service\BookingConfigurator;
use App\Service\BookingSessionStore;
use App\Service\BookingSessionManager;
use App\Service\ParticipantEligibilityChecker;
use App\Service\TravelDataProvider;
use PHPUnit\Framework\TestCase;
@@ -31,7 +31,7 @@ class BookingConfiguratorBabyTest extends TestCase
$agencyLoader = $this->createMock(AgencyLoader::class);
$this->bookingService = new BookingConfigurator(
$this->createMock(BookingSessionStore::class),
$this->createMock(BookingSessionManager::class),
$travelDataService,
$this->participantEligibilityService,
$bookingStatusRuleRegistry,
@@ -12,7 +12,7 @@ use App\BusProNet\Service\BookingStatusRuleRegistry;
use App\BusProNet\XmlLoader\AgencyLoader;
use App\Exception\NoRoomsAvailableException;
use App\Service\BookingConfigurator;
use App\Service\BookingSessionStore;
use App\Service\BookingSessionManager;
use App\Service\ParticipantEligibilityChecker;
use App\Service\TravelDataProvider;
use PHPUnit\Framework\TestCase;
@@ -27,7 +27,7 @@ class BookingConfiguratorStatusTest extends TestCase
protected function setUp(): void
{
$bookingSessionService = $this->createMock(BookingSessionStore::class);
$bookingSessionService = $this->createMock(BookingSessionManager::class);
$this->travelDataService = $this->createMock(TravelDataProvider::class);
$participantEligibility = $this->createMock(ParticipantEligibilityChecker::class);
$bookingStatusRuleRegistry = $this->createMock(BookingStatusRuleRegistry::class);
@@ -178,7 +178,7 @@ class BookingConfiguratorStatusTest extends TestCase
$bookingStatusRuleRegistry->method('evaluateStatus')->willReturn('O');
$bookingService = new BookingConfigurator(
$this->createMock(BookingSessionStore::class),
$this->createMock(BookingSessionManager::class),
$this->travelDataService,
$this->createMock(ParticipantEligibilityChecker::class),
$bookingStatusRuleRegistry,
@@ -209,7 +209,7 @@ class BookingConfiguratorStatusTest extends TestCase
$bookingStatusRuleRegistry->expects($this->never())->method('evaluateStatus');
$bookingService = new BookingConfigurator(
$this->createMock(BookingSessionStore::class),
$this->createMock(BookingSessionManager::class),
$this->travelDataService,
$this->createMock(ParticipantEligibilityChecker::class),
$bookingStatusRuleRegistry,
+4 -4
View File
@@ -16,7 +16,7 @@ use App\Service\BookingEditDataLoader;
use App\Service\BookingEditDraftManager;
use App\Service\BookingEditSubmitGuard;
use App\Service\BookingEditSubmitter;
use App\Service\BookingSessionStore;
use App\Service\BookingSessionManager;
use App\Service\TravelDataProvider;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
@@ -210,7 +210,7 @@ class BookingEditSubmitterTest extends TestCase
->with($bookingDto, true)
->willReturn($bookingUpdate);
$bookingSessionService = $this->createMock(BookingSessionStore::class);
$bookingSessionService = $this->createMock(BookingSessionManager::class);
$bookingSessionService->expects($this->once())
->method('clearBookingDto')
->with($request, BookingDto::MODE_EDIT);
@@ -276,7 +276,7 @@ class BookingEditSubmitterTest extends TestCase
->with($bookingDto, true)
->willReturn($bookingUpdate);
$bookingSessionService = $this->createMock(BookingSessionStore::class);
$bookingSessionService = $this->createMock(BookingSessionManager::class);
$bookingSessionService->expects($this->once())
->method('saveBookingDto')
->with($request, $bookingDto, BookingDto::MODE_EDIT);
@@ -435,7 +435,7 @@ class BookingEditSubmitterTest extends TestCase
$draftService ?? $this->createMock(BookingEditDraftManager::class),
$travelDataService ?? $this->createMock(TravelDataProvider::class),
$submitGuard ?? $this->createMock(BookingEditSubmitGuard::class),
$bookingSessionService ?? $this->createMock(BookingSessionStore::class),
$bookingSessionService ?? $this->createMock(BookingSessionManager::class),
$this->createUrlGenerator(),
$this->createMock(LoggerInterface::class),
);
@@ -6,31 +6,32 @@ namespace App\Tests\Service;
use App\BusProNet\Model\Booking;
use App\BusProNet\Model\Travel;
use App\Exception\BookingSessionNotFoundException;
use App\Form\Model\BookingDto;
use App\Form\Model\RoomSelectionDto;
use App\Service\BookingSessionStore;
use App\Service\BookingSessionManager;
use App\Service\TravelDataProvider;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
class BookingSessionStoreTest extends TestCase
class BookingSessionManagerTest extends TestCase
{
private TravelDataProvider $travelDataService;
private BookingSessionStore $service;
private BookingSessionManager $service;
protected function setUp(): void
{
$this->travelDataService = $this->createMock(TravelDataProvider::class);
$this->service = new BookingSessionStore($this->travelDataService);
$this->service = new BookingSessionManager($this->travelDataService);
}
public function testGetOrCreateBookingCreateDtoThrowsWhenSessionMissing(): void
{
$request = $this->createRequestWithSession();
$this->expectException(\App\Exception\BookingSessionNotFoundException::class);
$this->expectException(BookingSessionNotFoundException::class);
$this->service->getOrCreateBookingCreateDto($request);
}
@@ -91,7 +92,7 @@ class BookingSessionStoreTest extends TestCase
$this->service->storeReturnUrl($request, 'javascript:alert(1)');
$this->assertSame(BookingSessionStore::DEFAULT_RETURN_URL, $this->service->getReturnUrl($request));
$this->assertSame(BookingSessionManager::DEFAULT_RETURN_URL, $this->service->getReturnUrl($request));
}
public function testClearBookingSessionPreservesReturnUrl(): void