feat: dummy data fill

closes #869c3khk0
This commit is contained in:
Björn Fromme
2026-02-14 15:56:56 +01:00
parent 350a9e6742
commit abeb91b59f
3 changed files with 266 additions and 12 deletions
@@ -4,11 +4,13 @@ declare(strict_types=1);
namespace App\Controller\Booking\Create;
use App\BusProNet\Constants;
use App\Controller\Booking\Traits\BookingCreateTrait;
use App\Controller\Booking\Traits\BookingExceptionHandlerTrait;
use App\Controller\Booking\Traits\ParticipantCardFlowTrait;
use App\Form\BookingCreateStep2Type;
use App\Form\Model\BookingDto;
use App\Form\Service\DummyDataFillService;
use App\Form\Service\ParticipantFieldOptionsProvider;
use App\Htmx\HxTrait;
use App\Service\BookingService;
@@ -18,6 +20,7 @@ use App\Service\ParticipantPrepopulationService;
use App\Service\RoomAssignmentService;
use App\Service\TravelDataService;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
@@ -43,6 +46,7 @@ class Step2Controller extends AbstractController
private readonly ParticipantCardDataService $participantCardService,
private readonly ParticipantFieldOptionsProvider $fieldOptionsProvider,
private readonly ParticipantPrepopulationService $prepopulationService,
private readonly DummyDataFillService $dummyDataFillService,
) {
}
@@ -146,6 +150,22 @@ class Step2Controller extends AbstractController
$form->handleRequest($request);
// Detect dummy data fill token — render pre-filled form immediately, skipping validation
$isDummyDataFill = $this
->dummyDataFillService
->isTokenMatch($bookingDto->participants[$index], $bookingDto->getMode())
;
if (true === $form->isSubmitted() && true === $isDummyDataFill) {
$this->dummyDataFillService->fill($bookingDto->participants[$index], $index);
$bookingDto->bookingStatus = Constants::BOOKING_STATUS_OPEN;
$this->bookingService->saveBookingDto($request, $bookingDto, BookingDto::MODE_CREATE);
// Recreate form with filled DTO so the view shows the dummy data
$form = $this->createParticipantForm($bookingDto, $index);
return $this->renderParticipantForm($form, $index, $bookingDto);
}
// Collect notifications from field handlers (run during PRE_SUBMIT)
$notifications = $this->collectAndClearNotifications($bookingDto);
@@ -160,18 +180,7 @@ class Step2Controller extends AbstractController
return $this->redirectToRoute('app_booking_create_step_2');
}
// Get complete summary data (pricing, rooms, CMS data)
$summaryData = $this->summaryDataService->getSummaryData($bookingDto);
$templateData = [
'form' => $form->createView(),
'participantIndex' => $index,
'bookingDto' => $bookingDto,
'summaryData' => $summaryData,
'refreshRouteName' => 'app_booking_create_step_2_participant_refresh',
];
return $this->render('booking/create/step_2_participant.html.twig', $templateData);
return $this->renderParticipantForm($form, $index, $bookingDto);
}
/**
@@ -207,4 +216,18 @@ class Step2Controller extends AbstractController
'app_booking_create_step_2_participant_refresh'
);
}
private function renderParticipantForm(
FormInterface $form,
int $index,
BookingDto $bookingDto,
): Response {
return $this->render('booking/create/step_2_participant.html.twig', [
'form' => $form->createView(),
'participantIndex' => $index,
'bookingDto' => $bookingDto,
'summaryData' => $this->summaryDataService->getSummaryData($bookingDto),
'refreshRouteName' => 'app_booking_create_step_2_participant_refresh',
]);
}
}