wip: refactor forms

This commit is contained in:
Björn Fromme
2026-03-16 11:59:09 +01:00
parent 8da77ee13b
commit 1f5877460b
5 changed files with 54 additions and 29 deletions
@@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
namespace App\Form\Service;
use App\Form\Model\BookingCreateDto;
/**
* Central service for configuring dynamic fields in the participant form.
*
* This class encapsulates all business logic for determining field options,
* choices, and states (e.g., visibility, disabled status) based on the
* overall booking state and individual participant data.
*/
class ParticipantFormConfigurator
{
public function __construct(
private readonly ParticipantRoomChoiceLoaderFactory $roomChoiceLoaderFactory,
)
{
}
/**
* Gets the complete form options for the 'assignedRoomId' field.
*/
public function getRoomFieldOptions(BookingCreateDto $bookingDto, int $participantIndex): array
{
$choiceLoader = $this->roomChoiceLoaderFactory->create(
$bookingDto->participants,
$bookingDto->getSelectedRooms(),
$participantIndex
);
return [
'label' => 'Zimmer',
'placeholder' => 'Bitte wählen',
'choice_loader' => $choiceLoader,
];
}
}