Files
myep/src/Form/Service/Condition/FinalBookingOnlyCondition.php
T
2026-03-16 12:02:59 +01:00

46 lines
1.4 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Form\Service\Condition;
use App\BusProNet\Constants;
use App\Form\Model\BookingDto;
use App\Form\Service\Contract\FieldConditionInterface;
/**
* Condition that checks if the booking is not an inquiry booking.
*
* This condition is used to exclude certain fields (like vouchers) from inquiry
* bookings where they are not applicable. When a booking has inquiry status ('A'),
* fields with this condition will be excluded from the form.
*
* Returns true for both final ('F') and option ('O') bookings.
*/
class FinalBookingOnlyCondition implements FieldConditionInterface
{
/**
* Evaluates if the booking is not an inquiry booking.
*
* @param BookingDto $bookingDto The current booking data (create or edit)
* @param int $participantIndex The index of the participant being evaluated
* @param array<string, mixed> $formData Current form data (unused)
*
* @return bool True if booking status is not 'A' (inquiry), false otherwise
*/
public function evaluate(BookingDto $bookingDto, int $participantIndex, array $formData): bool
{
return Constants::BOOKING_STATUS_INQUIRY !== $bookingDto->bookingStatus;
}
public function getDependentFields(): array
{
return [];
}
public function getDescription(): string
{
return 'Only available for non-inquiry bookings (final or option)';
}
}