feat: special treatment of participants with age 0-2 (babies)

This commit is contained in:
Björn Fromme
2026-03-16 11:59:12 +01:00
parent cd1ffc3e9a
commit 2e40cbc7c7
12 changed files with 615 additions and 15 deletions
@@ -9,8 +9,6 @@ use Symfony\Component\Validator\Constraint;
#[\Attribute]
class RoomSelection extends Constraint
{
public const BABY_ROOM_CODE = 'Baby';
public string $noRoomSelectedMessage = 'Bitte mindestens ein Zimmer/Bett auswählen';
public string $onlyBabyRoomsMessage = 'Baby-Zimmer können nur in Kombination mit regulären Zimmern gebucht werden.';
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace App\Validator\Constraints;
use App\BusProNet\Constants;
use App\Form\Model\BookingDto;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
@@ -50,14 +51,14 @@ class RoomSelectionValidator extends ConstraintValidator
continue;
}
if (RoomSelection::BABY_ROOM_CODE === $room->code) {
if (Constants::BABY_ROOM_CODE === $room->code) {
$hasBabyRoom = true;
} else {
$hasRegularRoom = true;
}
}
if ($hasBabyRoom && !$hasRegularRoom) {
if ($hasBabyRoom && false === $hasRegularRoom) {
$this->context->buildViolation($constraint->onlyBabyRoomsMessage)
->addViolation();
}