Files
myep/src/Form/Service/ParticipantPromoVoucherFieldHandler.php
T

56 lines
2.0 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Form\Service;
use App\Form\Model\BookingDto;
use App\Form\Service\Abstract\AbstractParticipantFieldHandler;
/**
* Handles promotional voucher code field processing.
*
* Validation is performed by the PromoVoucher constraint on ParticipantEditDto.
* This handler maintains dependency order to ensure validation occurs after
* all price-affecting fields have been processed.
*
* Dependencies: ALL price-affecting fields (insurance, services, ski pass, rentals, etc.)
* since promo validation requires accurate participant pricing.
*/
class ParticipantPromoVoucherFieldHandler extends AbstractParticipantFieldHandler
{
public function getFieldName(): string
{
return 'promoVoucherCode';
}
public function getDependencies(): array
{
// CRITICAL: Must run after ALL price-affecting handlers to ensure accurate pricing
return [
'dateOfBirth', // Required for age-based services
'skiPass', // Affects travel price
'rentals', // Affects travel price
'courses', // Affects travel price
'additionalServices', // Affects travel price
'board', // Affects travel price
'transportationOutbound', // Affects travel price
'transportationInbound', // Affects travel price
'pickup', // Affects travel price
'parking', // Affects travel price
'insurance', // Affects travel price (must be last)
];
}
public function shouldProcess(array $submittedData, string $mode, int $participantIndex): bool
{
// No processing needed - validation handled by PromoVoucher constraint
return false;
}
public function processField(array $submittedData, BookingDto $bookingDto, int $participantIndex): void
{
// No processing needed - validation handled by PromoVoucher constraint
}
}