wip: major refactoring
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Form\Service;
|
||||
|
||||
use App\Form\Service\Abstract\AbstractFieldStateProvider;
|
||||
|
||||
/**
|
||||
* Field state provider for the booking create workflow.
|
||||
*
|
||||
* This service calculates dynamic field states (readonly, disabled, etc.)
|
||||
* for participant fields in the create flow. It extends the common field
|
||||
* state functionality provided by AbstractFieldStateProvider.
|
||||
*
|
||||
* Currently, no specific field state conditions are implemented for the
|
||||
* create workflow, but the infrastructure is ready for future additions.
|
||||
*/
|
||||
class CreateFieldStateProvider extends AbstractFieldStateProvider
|
||||
{
|
||||
/**
|
||||
* Registers field state conditions for the create workflow.
|
||||
*
|
||||
* This method defines the conditional logic for field states in the
|
||||
* booking creation process. Each field can have multiple state conditions
|
||||
* (readonly, disabled, hidden, required) that are evaluated independently.
|
||||
*
|
||||
* Adding new field state conditions:
|
||||
* To add conditional state logic for a field, register conditions here:
|
||||
*
|
||||
* $this->fieldStateConditions['fieldName'] = [
|
||||
* 'readonly' => new SomeCondition(),
|
||||
* 'disabled' => CompositeCondition::and(
|
||||
* new AgeRangeCondition(null, 17),
|
||||
* FieldValueCondition::equals('someField', 'someValue')
|
||||
* ),
|
||||
* ];
|
||||
*
|
||||
* Condition Types:
|
||||
* - 'readonly': Field is visible but not editable
|
||||
* - 'disabled': Field interaction is disabled
|
||||
* - 'required': Field becomes mandatory
|
||||
* - 'hidden': Field is not displayed
|
||||
*/
|
||||
protected function registerFieldStateConditions(): void
|
||||
{
|
||||
// Example field state conditions would be registered here
|
||||
// For demonstration purposes, here are some example patterns:
|
||||
|
||||
// Example 1: Make assignedRoomId readonly for participants under 18
|
||||
// $this->fieldStateConditions['assignedRoomId'] = [
|
||||
// 'readonly' => new AgeRangeCondition(null, 17),
|
||||
// ];
|
||||
|
||||
// Example 2: Disable service selection if no room is assigned
|
||||
// $this->fieldStateConditions['serviceSelection'] = [
|
||||
// 'disabled' => FieldValueCondition::isEmpty('assignedRoomId'),
|
||||
// ];
|
||||
|
||||
// Example 3: Complex condition with multiple criteria
|
||||
// $this->fieldStateConditions['advancedOptions'] = [
|
||||
// 'hidden' => CompositeCondition::or(
|
||||
// new AgeRangeCondition(null, 15),
|
||||
// FieldValueCondition::equals('userType', 'basic')
|
||||
// ),
|
||||
// ];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user