wip: refactor forms
This commit is contained in:
@@ -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,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user