52 lines
1.6 KiB
PHP
52 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Form\Service;
|
|
|
|
use App\Form\Service\Abstract\AbstractFieldStateProvider;
|
|
use App\Form\Service\Condition\ApplicantCondition;
|
|
use App\Form\Service\Condition\CompositeCondition;
|
|
use App\Form\Service\Condition\MutabilityCondition;
|
|
|
|
/**
|
|
* Field state provider for the booking edit workflow.
|
|
*
|
|
* This service calculates dynamic field states (readonly, disabled, etc.)
|
|
* for participant fields in the edit flow, using edit-specific conditions.
|
|
*
|
|
* It extends the common field state functionality provided by
|
|
* AbstractFieldStateProvider and adds edit-specific field state logic.
|
|
*/
|
|
class EditFieldStateProvider extends AbstractFieldStateProvider
|
|
{
|
|
/**
|
|
* Registers field state conditions for the edit workflow.
|
|
*
|
|
* This method defines the conditional logic for field states in the
|
|
* booking edit process. It makes personal data fields readonly when
|
|
* the participant is the applicant or when the field is not mutable.
|
|
*/
|
|
protected function registerFieldStateConditions(): void
|
|
{
|
|
// Make all personal data fields readonly if not mutable OR if applicant
|
|
$personalDataFields = [
|
|
'firstName',
|
|
'lastName',
|
|
'dateOfBirth',
|
|
'gender',
|
|
'nationality',
|
|
'email',
|
|
'mobile',
|
|
];
|
|
foreach ($personalDataFields as $field) {
|
|
$this->fieldStateConditions[$field] = [
|
|
'readonly' => CompositeCondition::or(
|
|
new ApplicantCondition(),
|
|
new MutabilityCondition()
|
|
),
|
|
];
|
|
}
|
|
}
|
|
}
|