feat: refactor to cards
This commit is contained in:
@@ -100,6 +100,10 @@ class ParticipantAdditionalServicesFieldHandler extends AbstractParticipantField
|
||||
// Extract current service selections from submitted data
|
||||
$selectedServices = $this->getFieldValue($submittedData, $this->getFieldName()) ?? [];
|
||||
|
||||
// Debug: Log what was submitted
|
||||
$submittedIds = array_map(fn($s) => is_object($s) ? $s->id : $s, $selectedServices);
|
||||
error_log(sprintf('[AdditionalServices] Participant %d: Submitted service IDs: [%s]', $participantIndex, implode(', ', $submittedIds)));
|
||||
|
||||
// Get available additional services from travel data
|
||||
$availableServices = $bookingDto->travel->getAdditionalServicesBySubTypes(Constants::TOKEN_ADDITIONAL);
|
||||
|
||||
@@ -111,6 +115,10 @@ class ParticipantAdditionalServicesFieldHandler extends AbstractParticipantField
|
||||
$participantIndex
|
||||
);
|
||||
|
||||
// Debug: Log what passed validation
|
||||
$validIds = array_map(fn($s) => $s->id, $validSelections);
|
||||
error_log(sprintf('[AdditionalServices] Participant %d: Valid service IDs after filtering: [%s]', $participantIndex, implode(', ', $validIds)));
|
||||
|
||||
// Update participant with validated selections
|
||||
$participant->additionalServices = $validSelections;
|
||||
}
|
||||
@@ -173,17 +181,33 @@ class ParticipantAdditionalServicesFieldHandler extends AbstractParticipantField
|
||||
$service = $this->findServiceInAvailableServices($selectedService, $availableServices);
|
||||
|
||||
if (null === $service) {
|
||||
error_log(sprintf('[AdditionalServices] Participant %d: Service %s NOT FOUND in available services', $participantIndex, is_object($selectedService) ? $selectedService->id : $selectedService));
|
||||
return false; // Service not found in available services
|
||||
}
|
||||
|
||||
// Check if service has age constraints
|
||||
$ageEvaluator = new ServiceAgeEvaluator();
|
||||
if (false === $ageEvaluator->canEvaluate($service)) {
|
||||
error_log(sprintf('[AdditionalServices] Participant %d: Service %d (%s) has NO age constraints - VALID', $participantIndex, $service->id, $service->label));
|
||||
return true; // No age restrictions, service is valid
|
||||
}
|
||||
|
||||
// Validate service against participant's age
|
||||
return $ageEvaluator->isServiceAvailableForParticipant($service, $bookingDto, $participantIndex);
|
||||
$isValid = $ageEvaluator->isServiceAvailableForParticipant($service, $bookingDto, $participantIndex);
|
||||
$participant = $bookingDto->getParticipant($participantIndex);
|
||||
$age = $participant?->getAge($bookingDto->travel->dateFrom);
|
||||
|
||||
error_log(sprintf(
|
||||
'[AdditionalServices] Participant %d (age %s): Service %d (%s) age validation = %s. Constraints: %s',
|
||||
$participantIndex,
|
||||
$age ?? 'unknown',
|
||||
$service->id,
|
||||
$service->label,
|
||||
$isValid ? 'VALID' : 'INVALID',
|
||||
$ageEvaluator->getConstraintDescription($service)
|
||||
));
|
||||
|
||||
return $isValid;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user