wip: refactor

This commit is contained in:
Björn Fromme
2025-07-24 11:12:06 +02:00
parent 64d51c01b2
commit 3f94c51bc8
21 changed files with 395 additions and 110 deletions
@@ -4,7 +4,7 @@ declare(strict_types=1);
namespace App\Form\ParticipantFieldHandler\Condition;
use App\Form\Model\BookingCreateDto;
use App\Form\Model\BookingDtoInterface;
/**
* Condition that evaluates field states based on other field values.
@@ -59,13 +59,13 @@ class FieldValueCondition implements FieldConditionInterface
* against the expected value using the configured operator. Supports
* both participant-level fields and booking-level fields.
*
* @param BookingCreateDto $bookingDto The current booking data
* @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 for condition evaluation
*
* @return bool True if the field value meets the condition criteria, false otherwise
*/
public function evaluate(BookingCreateDto $bookingDto, int $participantIndex, array $formData): bool
public function evaluate(BookingDtoInterface $bookingDto, int $participantIndex, array $formData): bool
{
$fieldValue = $this->getFieldValue($formData, $participantIndex, $bookingDto);
@@ -174,7 +174,7 @@ class FieldValueCondition implements FieldConditionInterface
/**
* Retrieves field value from form data or participant data.
*/
private function getFieldValue(array $formData, int $participantIndex, BookingCreateDto $bookingDto): mixed
private function getFieldValue(array $formData, int $participantIndex, BookingDtoInterface $bookingDto): mixed
{
// First check participant-specific form data
if (isset($formData['participants'][$participantIndex][$this->fieldName])) {
@@ -182,7 +182,7 @@ class FieldValueCondition implements FieldConditionInterface
}
// Then check participant DTO data
$participant = $bookingDto->participants[$participantIndex] ?? null;
$participant = $bookingDto->getParticipant($participantIndex);
if (null !== $participant && property_exists($participant, $this->fieldName)) {
return $participant->{$this->fieldName};
}