> */ public function findMissingValueLabelsByParticipantIndex(BookingDto $bookingDto): array { if (BookingDto::MODE_EDIT !== $bookingDto->getMode()) { return []; } $missingValueLabelsByParticipantIndex = []; foreach ($bookingDto->participants as $index => $participant) { if (true === $participant->isCanceled()) { continue; } $missingValueLabels = $this->getMissingValueLabelsForParticipant($bookingDto, $participant); if ([] !== $missingValueLabels) { $missingValueLabelsByParticipantIndex[$index] = $missingValueLabels; } } return $missingValueLabelsByParticipantIndex; } /** * @return list */ private function getMissingValueLabelsForParticipant(BookingDto $bookingDto, ParticipantDto $participant): array { $participantForAudit = new ParticipantEditDto( participant: $participant, bookingContext: $bookingDto, ); $violations = $this->validator->validate( $participantForAudit, null, ['booking_edit', 'strict_required'] ); $valueLabels = []; foreach ($violations as $violation) { $valueLabel = $this->mapViolationToValueLabel($violation); if (null !== $valueLabel) { $valueLabels[] = $valueLabel; } } if (false === $bookingDto->isInternalAgencyBooking() && true === $participant->isApplicant()) { foreach ($this->getMissingValueAddressLabels($participant) as $valueLabel) { $valueLabels[] = $valueLabel; } } return array_values(array_unique($valueLabels)); } private function mapViolationToValueLabel(ConstraintViolationInterface $violation): ?string { $propertyPath = $violation->getPropertyPath(); if (str_starts_with($propertyPath, 'participant.')) { $propertyPath = substr($propertyPath, strlen('participant.')); } return match ($propertyPath) { 'firstName' => 'Vorname', 'lastName' => 'Nachname', 'gender' => 'Anrede', 'nationality' => 'Nationalität', 'dateOfBirth' => 'Geburtsdatum', 'email' => 'E-Mail', 'height' => 'Körpergröße', 'weight' => 'Gewicht', 'shoeSize' => 'Schuhgröße', 'assignedRoomId' => 'Zimmer', 'transportationOutbound' => 'Anreise', 'pickup' => 'Zustieg', 'transportationInbound' => 'Abreise', 'dropOff' => 'Ausstieg', default => null, }; } /** * @return list */ private function getMissingValueAddressLabels(ParticipantDto $participant): array { if (null === $participant->address) { return ['Adresse']; } $valueLabels = []; $violations = $this->validator->validate($participant->address, null, ['personal_data']); foreach ($violations as $violation) { $valueLabel = match ($violation->getPropertyPath()) { 'street' => 'Straße', 'postCode' => 'PLZ', 'city' => 'Ort', 'country' => 'Land', default => null, }; if (null !== $valueLabel) { $valueLabels[] = $valueLabel; } } return array_values(array_unique($valueLabels)); } }