participant; if (true === $participant->isCanceled()) { return; } $participantIndex = $participant->index ?? 0; if (false === $this->participantEligibilityService->isParticipantEligible($value->bookingContext, $participantIndex)) { return; } $mandatoryAdditionalServices = array_filter( $value->bookingContext->travel->getAdditionalServicesBySubTypes(Constants::TOKEN_ADDITIONAL), function (Service $service) use ($value, $participantIndex): bool { if (true !== $service->mandatory) { return false; } if (true === $this->serviceAgeEvaluator->canEvaluate($service)) { return $this->serviceAgeEvaluator->isServiceAvailableForParticipant( $service, $value->bookingContext, $participantIndex ); } return true; } ); if (true === empty($mandatoryAdditionalServices)) { return; } $selectedAdditionalServiceIds = array_map( static fn (Service $service): int => $service->id, $participant->additionalServices ); foreach ($mandatoryAdditionalServices as $mandatoryService) { if (false === in_array($mandatoryService->id, $selectedAdditionalServiceIds, true)) { $this->context->buildViolation($constraint->message) ->atPath('participant.additionalServices') ->addViolation(); return; } } } }