wip: finalize implementation

This commit is contained in:
Björn Fromme
2025-10-17 18:46:25 +02:00
parent dc7ed0728a
commit 434c4d0a11
20 changed files with 112 additions and 224 deletions
@@ -62,13 +62,13 @@ class Step4Controller extends AbstractController
]);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
if (true === $form->isSubmitted() && true === $form->isValid()) {
try {
// Submit final booking (already validated in Step 3)
$bookingResponse = $this->apiClient->createBooking($bookingCreateDto);
if ($bookingResponse instanceof Notification) {
return $this->handleBookingError(
return $this->handleApiError(
'Booking creation failed - API notification',
['message' => $bookingResponse->message],
$bookingResponse->message,
@@ -78,7 +78,7 @@ class Step4Controller extends AbstractController
}
if (false === $bookingResponse->isBookingSuccessful()) {
return $this->handleBookingError(
return $this->handleApiError(
'Booking creation unsuccessful',
['status' => $bookingResponse->status],
'Buchung konnte nicht erstellt werden.',
@@ -93,7 +93,7 @@ class Step4Controller extends AbstractController
return $this->hxRedirect($request, $this->generateUrl('app_booking_create_success'));
} catch (\Exception $e) {
return $this->handleBookingError(
return $this->handleApiError(
'Booking creation exception',
[
'exception' => $e->getMessage(),
@@ -109,22 +109,6 @@ class Step4Controller extends AbstractController
return $this->renderStepForm($bookingCreateDto, $form);
}
/**
* Handles booking errors by logging, adding flash message, and rendering the form.
*/
private function handleBookingError(
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 4 form with standard template variables.
*/