wip: form refactoring

This commit is contained in:
Björn Fromme
2025-07-25 09:28:13 +02:00
parent 2b122a7cc4
commit ae2ed306b9
13 changed files with 158 additions and 100 deletions
-5
View File
@@ -40,11 +40,6 @@ class BookingCreateDto implements BookingDtoInterface
return $this->participants;
}
public function getTravel(): Travel
{
return $this->travel;
}
public function hasParticipant(int $index): bool
{
return isset($this->participants[$index]);
+1 -17
View File
@@ -4,8 +4,6 @@ declare(strict_types=1);
namespace App\Form\Model;
use App\BusProNet\Model\Travel;
/**
* Interface for unified access to booking data across create and edit workflows.
*
@@ -23,13 +21,6 @@ interface BookingDtoInterface
*/
public function getParticipants(): array;
/**
* Gets the travel data for the booking.
*
* @return Travel The travel data containing services, hotels, and other booking options
*/
public function getTravel(): Travel;
/**
* Checks if a participant exists at the given index.
*
@@ -47,11 +38,4 @@ interface BookingDtoInterface
* @return ParticipantDto|null The participant DTO or null if not found
*/
public function getParticipant(int $index): ?ParticipantDto;
/**
* Gets all selected rooms for the booking.
*
* @return array<int, RoomSelectionDto> Array of selected room DTOs (may be empty for edit DTOs)
*/
public function getSelectedRooms(): array;
}
}
+6 -10
View File
@@ -10,18 +10,19 @@ use Symfony\Component\Validator\Constraints as Assert;
class BookingEditDto implements BookingDtoInterface
{
public ?Booking $booking = null;
public ?Travel $travel = null;
/**
* @var array<int, ParticipantDto>
*/
#[Assert\Valid]
public array $participants = [];
public function __construct(public Booking $booking, public Travel $travel)
{
}
public static function fromBooking(Booking $booking, Travel $travel): static
{
$instance = new static();
$instance = new static($booking, $travel);
$instance->booking = $booking;
$instance->travel = $travel;
@@ -69,11 +70,6 @@ class BookingEditDto implements BookingDtoInterface
return $this->participants;
}
public function getTravel(): Travel
{
return $this->travel;
}
public function hasParticipant(int $index): bool
{
return isset($this->participants[$index]);
@@ -87,7 +83,7 @@ class BookingEditDto implements BookingDtoInterface
/**
* Gets all selected rooms for the booking (edit context).
*
* @return array<int, RoomSelectionDto> Always returns an empty array for edit DTOs unless implemented.
* @return array<int, RoomSelectionDto> always returns an empty array for edit DTOs unless implemented
*/
public function getSelectedRooms(): array
{