feat: selectable drop-offs for inbound bus travel
This commit is contained in:
@@ -22,6 +22,7 @@ class ParticipantValidator extends ConstraintValidator
|
||||
$participant = $value;
|
||||
|
||||
$this->assertPickupSelected($participant);
|
||||
$this->assertDropOffSelected($participant);
|
||||
$this->assertBodyDimensionsWhenRentalsSelected($participant);
|
||||
}
|
||||
|
||||
@@ -42,6 +43,29 @@ class ParticipantValidator extends ConstraintValidator
|
||||
}
|
||||
}
|
||||
|
||||
public function assertDropOffSelected(ParticipantDto $participant): void
|
||||
{
|
||||
$hasOutboundBus = null !== $participant->transportationOutbound
|
||||
&& 'BUS' === $participant->transportationOutbound->subType;
|
||||
$hasInboundBus = null !== $participant->transportationInbound
|
||||
&& 'BUS' === $participant->transportationInbound->subType;
|
||||
|
||||
if (false === $hasInboundBus) {
|
||||
return;
|
||||
}
|
||||
|
||||
// BUS+BUS: drop-off required only when differentDropOff checkbox is checked
|
||||
// PKW+BUS: drop-off always required (no checkbox, field shown directly)
|
||||
$requireDropOff = $hasOutboundBus ? $participant->differentDropOff : true;
|
||||
|
||||
if ($requireDropOff && null === $participant->dropOff) {
|
||||
$this->context->buildViolation('Bitte auswählen')
|
||||
->atPath('dropOff')
|
||||
->addViolation()
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
public function assertBodyDimensionsWhenRentalsSelected(ParticipantDto $participant): void
|
||||
{
|
||||
// Check if any rental services are selected
|
||||
|
||||
Reference in New Issue
Block a user