64 lines
2.0 KiB
PHP
64 lines
2.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Controller\Booking;
|
|
|
|
use App\Controller\Traits\HtmxControllerTrait;
|
|
use App\Form\BookingCreateStep4Type;
|
|
use App\Service\BookingService;
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
use Symfony\Component\Routing\Attribute\Route;
|
|
/**
|
|
* Handles the fourth step of the booking creation process (confirmation).
|
|
*/
|
|
class CreateStep4Controller extends AbstractController
|
|
{
|
|
use BookingCreateTrait;
|
|
use BookingExceptionHandlerTrait;
|
|
use HtmxControllerTrait;
|
|
|
|
public function __construct(
|
|
private readonly BookingService $bookingService,
|
|
) {
|
|
}
|
|
|
|
/**
|
|
* Displays booking summary and confirmation form.
|
|
*/
|
|
#[Route('/bookings/create/confirmation', name: 'app_booking_create_step_4')]
|
|
public function step4(Request $request): Response
|
|
{
|
|
$result = $this->getOrCreateBookingCreateDto($this->bookingService, $request);
|
|
if ($result instanceof Response) {
|
|
return $result;
|
|
}
|
|
$bookingCreateDto = $result;
|
|
|
|
// Validate step access
|
|
if ($redirect = $this->validateStepAccess($bookingCreateDto, 4)) {
|
|
return $redirect;
|
|
}
|
|
|
|
$form = $this->createForm(BookingCreateStep4Type::class, $bookingCreateDto);
|
|
$form->handleRequest($request);
|
|
|
|
if ($form->isSubmitted() && $form->isValid()) {
|
|
// TODO: Perform inquiry API call
|
|
// TODO: If inquiry successful, perform booking API call
|
|
// TODO: Clear session and redirect to success page
|
|
|
|
$this->addFlash('success', 'Buchung erfolgreich abgeschlossen.');
|
|
|
|
return $this->redirectToRoute('app_booking_create_step_4');
|
|
}
|
|
|
|
return $this->render('booking/create_step_4.html.twig', [
|
|
'bookingCreateDto' => $bookingCreateDto,
|
|
'form' => $form->createView(),
|
|
...$this->getSummaryVariables($bookingCreateDto),
|
|
]);
|
|
}
|
|
} |