wip: finalize implementation

This commit is contained in:
Björn Fromme
2026-03-16 11:59:11 +01:00
parent b882175f36
commit 5ef3bb9cbf
20 changed files with 112 additions and 224 deletions
@@ -64,13 +64,14 @@ class Step3Controller extends AbstractController
]);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
if (true === $form->isSubmitted() && true === $form->isValid()) {
try {
// Validate booking data with API (inquiry)
$bookingCreateDto->bookingStatus = 'A';
$inquiryResponse = $this->apiClient->createBookingInquiry($bookingCreateDto);
if ($inquiryResponse instanceof Notification) {
return $this->handleInquiryError(
return $this->handleApiError(
'Booking inquiry failed',
['message' => $inquiryResponse->message],
'Ein Fehler ist aufgetreten. Bitte versuchen Sie es erneut.',
@@ -80,7 +81,7 @@ class Step3Controller extends AbstractController
}
if (false === $inquiryResponse->isInquiryValid()) {
return $this->handleInquiryError(
return $this->handleApiError(
'Booking inquiry validation failed',
['status' => $inquiryResponse->status],
'Buchung konnte nicht validiert werden.',
@@ -94,7 +95,7 @@ class Step3Controller extends AbstractController
$calculatedTotal = $this->priceCalculator->calculateGrandTotal($bookingCreateDto);
if ($apiTotal !== $calculatedTotal) {
return $this->handleInquiryError(
return $this->handleApiError(
'Price mismatch detected - payload incomplete',
[
'apiTotal' => $apiTotal,
@@ -111,9 +112,13 @@ class Step3Controller extends AbstractController
$bookingCreateDto->currentStep = 4;
$this->bookingService->saveBookingCreateDto($request, $bookingCreateDto);
if ($inquiryResponse->message) {
$this->addFlash('info', $inquiryResponse->message);
}
return $this->hxRedirect($request, $this->generateUrl('app_booking_create_step_4'));
} catch (\Exception $e) {
return $this->handleInquiryError(
return $this->handleApiError(
'Booking inquiry exception',
[
'exception' => $e->getMessage(),
@@ -151,22 +156,6 @@ class Step3Controller extends AbstractController
return $this->renderStepForm($bookingCreateDto, $form);
}
/**
* Handles inquiry errors by logging, adding flash message, and rendering the form.
*/
private function handleInquiryError(
string $logMessage,
array $context,
string $flashMessage,
BookingDto $bookingCreateDto,
FormInterface $form,
): Response {
$this->logger->error($logMessage, $context);
$this->addFlash('error', $flashMessage);
return $this->renderStepForm($bookingCreateDto, $form);
}
/**
* Renders the step 3 form with standard template variables.
*/