chore: further cleanup and refactor

This commit is contained in:
Björn Fromme committed 2026-04-19 15:45:02 +02:00
1 parent 5a0bf11c81
commit 80969d1da0
21 files changed
+606 -321

No files matched your search

@@ -5,19 +5,20 @@ declare(strict_types=1);
namespace App\Controller\Booking\Create;
use App\BusProNet\Model\Travel;
use App\Controller\Booking\Traits\BookingCreateTrait;
use App\Controller\Booking\Traits\BookingExceptionHandlerTrait;
use App\Exception\BookingSessionNotFoundException;
use App\Exception\HotelNotInTravelException;
use App\Exception\TravelNotFoundException;
use App\Entity\User;
use App\Form\BookingCreateStep2Type;
use App\Form\Model\BookingDto;
use App\Form\Model\ParticipantDto;
use App\Form\Model\RoomSelectionDto;
use App\Service\BookingConfigurator;
use App\Service\BookingCreateContextFactory;
use App\Service\BookingSessionManager;
use App\Service\ParticipantDataPrefiller;
use App\Service\RoomAssigner;
use App\Service\TravelDataProvider;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
@@ -28,11 +29,8 @@ use Symfony\Component\Routing\Attribute\Route;
* This controller uses a card overview and lazy-loaded individual participant forms
* for better performance and UX with large groups (50+ participants).
*/
class Step2Controller extends AbstractController
class Step2Controller extends AbstractBookingCreateController
{
use BookingCreateTrait;
use BookingExceptionHandlerTrait;
public function __construct(
private readonly BookingConfigurator $bookingService,
private readonly BookingSessionManager $bookingSessionService,
@@ -49,15 +47,14 @@ class Step2Controller extends AbstractController
#[Route('/bookings/create/participants', name: 'app_booking_create_step_2')]
public function index(Request $request): Response
{
// Load or create booking DTO
$result = $this->getOrCreateBookingCreateDto($this->bookingSessionService, $request);
if ($result instanceof Response) {
return $result;
try {
$bookingCreateDto = $this->loadBookingCreateDto($this->bookingSessionService, $request);
} catch (BookingSessionNotFoundException|TravelNotFoundException|HotelNotInTravelException $exception) {
return $this->createBookingCreateFailureResponse($exception, false);
}
$bookingCreateDto = $result;
// Validate step access
if ($redirect = $this->validateStepAccess($bookingCreateDto, 2)) {
if (null !== $redirect = $this->validateStepAccess($bookingCreateDto, 2)) {
return $redirect;
}
@@ -132,7 +129,9 @@ class Step2Controller extends AbstractController
}
}
/** @param array<int, \App\Form\Model\RoomSelectionDto> $roomSelections */
/**
* @param array<int, RoomSelectionDto> $roomSelections
*/
private function calculateParticipantsCount(array $roomSelections, Travel $travelData): int
{
$participantsCount = 0;