wip: booking process, refactoring

This commit is contained in:
Björn Fromme
2025-07-16 19:37:17 +02:00
parent 47faa6b08e
commit eecea0abd1
43 changed files with 2269 additions and 366 deletions
+11 -4
View File
@@ -9,7 +9,7 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
class BookingCreateDto
{
public int $currentStep = 1;
#[Assert\Valid]
/**
* @var array<int, RoomSelectionDto>
@@ -26,7 +26,7 @@ class BookingCreateDto
{
}
#[Assert\Callback]
#[Assert\Callback(groups: ['booking_create_step_1'])]
public function assertValidRoomSelections(ExecutionContextInterface $context): void
{
$participantsCount = $this->getParticipantsCount();
@@ -57,8 +57,15 @@ class BookingCreateDto
foreach ($this->roomSelections as $roomSelection) {
$room = $rooms[$roomSelection->roomId];
$participantsCount += $room->minPax * $roomSelection->quantity;
}
}
return $participantsCount;
}
}
public function getSelectedRooms(): array
{
return array_filter($this->roomSelections, function (RoomSelectionDto $roomSelection) {
return 0 < $roomSelection->quantity;
});
}
}
+6 -6
View File
@@ -8,7 +8,7 @@ use App\BusProNet\Model\Service;
use App\Validator\Constraints as AppAssert;
use Symfony\Component\Validator\Constraints as Assert;
#[AppAssert\Participant]
#[AppAssert\Participant(groups: ['booking_edit'])]
class ParticipantDto
{
public ?int $index = null;
@@ -17,10 +17,10 @@ class ParticipantDto
public ?string $status = null;
public bool $mutable = false;
#[Assert\NotBlank(message: 'Bitte angeben')]
#[Assert\NotBlank(message: 'Bitte angeben', groups: ['booking_edit', 'booking_create_step_2'])]
public ?string $firstName = null;
#[Assert\NotBlank(message: 'Bitte angeben')]
#[Assert\NotBlank(message: 'Bitte angeben', groups: ['booking_edit', 'booking_create_step_2'])]
public ?string $lastName = null;
public ?string $title = null;
public ?string $gender = null;
@@ -29,11 +29,11 @@ class ParticipantDto
public ?string $shoeSize = null;
public ?string $weight = null;
#[Assert\NotNull(message: 'Bitte angeben')]
#[Assert\NotNull(message: 'Bitte angeben', groups: ['booking_edit', 'booking_create_step_2'])]
public ?\DateTimeImmutable $dateOfBirth = null;
#[Assert\NotBlank(message: 'Bitte angeben')]
#[Assert\Email(message: 'Bitte eine gültige E-Mail Adresse angeben', mode: 'strict')]
#[Assert\NotBlank(message: 'Bitte angeben', groups: ['booking_edit', 'booking_create_step_2'])]
#[Assert\Email(message: 'Bitte eine gültige E-Mail Adresse angeben', mode: 'strict', groups: ['booking_edit', 'booking_create_step_2'])]
public ?string $email = null;
public ?string $mobile = null;
+1 -1
View File
@@ -6,7 +6,7 @@ use Symfony\Component\Validator\Constraints as Assert;
class RoomSelectionDto
{
#[Assert\NotNull(message: 'Bitte eine Zimmerkategorie auswählen')]
#[Assert\NotNull(message: 'Bitte eine Zimmerkategorie auswählen', groups: ['booking_create_step_1'])]
public ?int $roomId = null;
public ?string $roomLabel = null;