wip: finalize implementation
This commit is contained in:
@@ -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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user