45 lines
1.4 KiB
PHP
45 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Form\Service\Condition;
|
|
|
|
use App\Form\Model\BookingDtoInterface;
|
|
use App\Form\Service\Contract\FieldConditionInterface;
|
|
|
|
/**
|
|
* Condition that checks if the participant is the applicant.
|
|
*
|
|
* This is used to apply field state logic (e.g., enable/disable fields)
|
|
* specifically for the applicant participant in the booking.
|
|
*
|
|
* The default logic assumes the applicant is the first participant (index 0),
|
|
* but this can be adjusted if your domain uses a different rule or property.
|
|
*/
|
|
class ApplicantCondition implements FieldConditionInterface
|
|
{
|
|
/**
|
|
* Evaluates if the participant is the applicant.
|
|
*
|
|
* @param BookingDtoInterface $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 the participant is the applicant, false otherwise
|
|
*/
|
|
public function evaluate(BookingDtoInterface $bookingDto, int $participantIndex, array $formData): bool
|
|
{
|
|
// Default: applicant is the first participant (index 0)
|
|
return $participantIndex === 0;
|
|
}
|
|
|
|
public function getDependentFields(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
public function getDescription(): string
|
|
{
|
|
return 'Checks if the participant is the applicant (index 0)';
|
|
}
|
|
} |