feat: refactor to cards

This commit is contained in:
Björn Fromme
2026-03-16 11:59:10 +01:00
parent 32a9fac9ed
commit e51c4843c5
40 changed files with 2639 additions and 3097 deletions
@@ -0,0 +1,81 @@
<?php
declare(strict_types=1);
namespace App\Controller\Booking\Traits;
use App\Form\Model\BookingDto;
use Symfony\Component\HttpFoundation\RedirectResponse;
/**
* Provides common functionality for booking creation controllers.
*
* This trait contains shared validation and redirect logic used across
* all booking creation steps to ensure consistent behavior and reduce
* code duplication.
*/
trait BookingCreateTrait
{
/**
* Validates step access and returns redirect response if necessary.
*
* @return RedirectResponse|null Returns redirect response if validation fails, null if access is allowed
*/
private function validateStepAccess(BookingDto $bookingCreateDto, int $expectedStep): ?RedirectResponse
{
// Allow access to current step or any previous step
if ($expectedStep > $bookingCreateDto->currentStep) {
$this->addFlash('error', 'Bitte erst die vorherigen Schritte abschließen.');
return $this->redirectToCurrentStep($bookingCreateDto);
}
return null;
}
/**
* Redirects to the current step based on the DTO's currentStep.
*/
private function redirectToCurrentStep(BookingDto $bookingCreateDto): RedirectResponse
{
$route = match ($bookingCreateDto->currentStep) {
2 => 'app_booking_create_step_2',
3 => 'app_booking_create_step_3',
4 => 'app_booking_create_step_4',
default => 'app_booking_create_step_1',
};
return $this->redirectToRoute($route);
}
/**
* Returns the total number of participants based on room selections.
*/
private function getParticipantsCount(BookingDto $bookingCreateDto): int
{
return $this
->bookingService
->getParticipantsCount($bookingCreateDto->roomSelections, $bookingCreateDto->travel);
}
/**
* Prepares template variables for the booking summary sidebar.
*
* @return array<string, mixed> Array containing all variables needed for the summary partial
*/
private function getSummaryVariables(BookingDto $bookingCreateDto): array
{
$participantsCount = $this->getParticipantsCount($bookingCreateDto);
$summary = $this->bookingService->getRoomSummaryAndParticipantCount($bookingCreateDto);
$roomAssignmentCounts = $this->bookingService->getRoomAssignmentCounts($bookingCreateDto);
$availableRooms = $bookingCreateDto->travel->getAvailableRooms();
$groupedSelectedRooms = $this->bookingService->groupRoomSelectionsByType($bookingCreateDto->getSelectedRooms(), $availableRooms);
return [
'participantsCount' => $participantsCount,
'pricingData' => $summary['pricing'],
'assignmentCounts' => $roomAssignmentCounts,
'groupedSelectedRooms' => $groupedSelectedRooms,
];
}
}