Files
myep/src/Form/Service/Condition/MutabilityCondition.php
T

50 lines
1.6 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Form\Service\Condition;
use App\Form\Model\BookingDto;
use App\Form\Service\Contract\FieldConditionInterface;
/**
* Condition that checks if a participant's personal data is mutable in the edit flow.
*
* This is used to set fields as readonly or disabled if the booking or participant
* is not allowed to be modified (e.g., after a certain workflow step or status).
*
* The logic assumes the BookingDto or its participant DTOs expose a
* 'personalDataMutable' property or method. Adjust as needed for your domain.
*/
class MutabilityCondition implements FieldConditionInterface
{
/**
* Evaluates if the participant's personal data is mutable.
*
* @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 the participant's data is mutable, false otherwise
*/
public function evaluate(BookingDto $bookingDto, int $participantIndex, array $formData): bool
{
$participant = $bookingDto->getParticipant($participantIndex);
if (null === $participant) {
return false;
}
return $participant->mutable;
}
public function getDependentFields(): array
{
return [];
}
public function getDescription(): string
{
return 'Checks if the participant\'s personal data is mutable (edit flow)';
}
}