wip: refactor forms

This commit is contained in:
Björn Fromme
2025-07-23 17:15:39 +02:00
parent f225dac5fe
commit 4ce731bfcb
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,
];
}
}