wip: refactor to cards with individual participant forms
This commit is contained in:
1 parent
33e1aea80c
commit
de8cbf6178
22 files changed
+866
-212
No files matched your search
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Form\Service;
|
||||
|
||||
use App\BusProNet\Model\Address;
|
||||
use App\BusProNet\Model\Insurance;
|
||||
use App\BusProNet\Model\Pickup;
|
||||
use App\BusProNet\Model\Service;
|
||||
@@ -132,13 +133,42 @@ class ParticipantFieldHandlerRegistry
|
||||
}
|
||||
|
||||
// Let each handler decide if it should process this participant's data
|
||||
if ($handler->shouldProcess($participantData, (int) $participantIndex)) {
|
||||
if ($handler->shouldProcess($participantData, $bookingDto->mode, (int) $participantIndex)) {
|
||||
$handler->processField($participantData, $bookingDto, (int) $participantIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes field handlers for a single participant.
|
||||
*
|
||||
* This method is used by the card-based booking flows where participants are
|
||||
* edited individually. Unlike processFields() which processes all participants,
|
||||
* this method applies all handlers to only the specified participant.
|
||||
*
|
||||
* Handlers are executed in dependency order to ensure proper data consistency.
|
||||
*
|
||||
* @param array<string, mixed> $participantData Submitted data for one participant
|
||||
* @param BookingDto $bookingDto The booking DTO to update
|
||||
* @param int $participantIndex Index of participant to process
|
||||
*/
|
||||
public function processFieldsForParticipant(array $participantData, BookingDto $bookingDto, int $participantIndex): void
|
||||
{
|
||||
// Get handlers sorted by dependency order (uses cache if available)
|
||||
$sortedHandlerNames = $this->getSortedHandlers();
|
||||
|
||||
// Apply each handler to the specified participant
|
||||
foreach ($sortedHandlerNames as $handlerName) {
|
||||
$handler = $this->handlers[$handlerName];
|
||||
|
||||
// Let each handler decide if it should process this participant's data
|
||||
if ($handler->shouldProcess($participantData, $bookingDto->mode, $participantIndex)) {
|
||||
$handler->processField($participantData, $bookingDto, $participantIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns handler names sorted by dependency order using cached results when possible.
|
||||
*
|
||||
@@ -376,7 +406,7 @@ class ParticipantFieldHandlerRegistry
|
||||
}
|
||||
|
||||
// Handle Address objects -> convert to array of properties
|
||||
if ($value instanceof \App\BusProNet\Model\Address) {
|
||||
if ($value instanceof Address) {
|
||||
return [
|
||||
'street' => $value->street,
|
||||
'postCode' => $value->postCode,
|
||||
|
||||
Reference in new issue
Block a user