wip: dynamic services fields
This commit is contained in:
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Form\Service;
|
||||
|
||||
use App\BusProNet\Model\Service;
|
||||
use App\Form\Model\BookingDtoInterface;
|
||||
use App\Form\Service\Contract\ParticipantFieldHandlerInterface;
|
||||
|
||||
@@ -98,7 +99,7 @@ class ParticipantFieldHandlerRegistry
|
||||
public function processFields(array $submittedData, BookingDtoInterface $bookingDto): void
|
||||
{
|
||||
// Early return if no participant data exists in submission
|
||||
if (!isset($submittedData['participants']) || !is_array($submittedData['participants'])) {
|
||||
if (false === isset($submittedData['participants']) || false === is_array($submittedData['participants'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -108,7 +109,7 @@ class ParticipantFieldHandlerRegistry
|
||||
// Process each participant's data
|
||||
foreach ($submittedData['participants'] as $participantIndex => $participantData) {
|
||||
// Skip invalid participant data
|
||||
if (!is_array($participantData)) {
|
||||
if (false === is_array($participantData)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -180,7 +181,7 @@ class ParticipantFieldHandlerRegistry
|
||||
foreach ($this->handlers as $handlerName => $handler) {
|
||||
foreach ($handler->getDependencies() as $dependency) {
|
||||
// Validate that the dependency exists
|
||||
if (!isset($this->handlers[$dependency])) {
|
||||
if (false === isset($this->handlers[$dependency])) {
|
||||
throw new \InvalidArgumentException(sprintf('Handler "%s" depends on unknown handler "%s"', $handlerName, $dependency));
|
||||
}
|
||||
|
||||
@@ -202,7 +203,7 @@ class ParticipantFieldHandlerRegistry
|
||||
}
|
||||
|
||||
// Process handlers in dependency order
|
||||
while (!empty($queue)) {
|
||||
while (false === empty($queue)) {
|
||||
$current = array_shift($queue);
|
||||
$result[] = $current;
|
||||
|
||||
@@ -243,13 +244,13 @@ class ParticipantFieldHandlerRegistry
|
||||
private function syncSubmittedDataWithDto(array $submittedData, BookingDtoInterface $bookingDto): array
|
||||
{
|
||||
// Ensure participants array exists in submitted data
|
||||
if (!isset($submittedData['participants']) || !is_array($submittedData['participants'])) {
|
||||
if (false === isset($submittedData['participants']) || false === is_array($submittedData['participants'])) {
|
||||
return $submittedData;
|
||||
}
|
||||
|
||||
// Sync each participant's data with the cleaned DTO
|
||||
foreach ($submittedData['participants'] as $index => $participantData) {
|
||||
if (!is_array($participantData)) {
|
||||
if (false === is_array($participantData)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -333,7 +334,7 @@ class ParticipantFieldHandlerRegistry
|
||||
private function convertSingleValueToSubmittedFormat(mixed $value): mixed
|
||||
{
|
||||
// Handle Service objects -> convert to ID
|
||||
if ($value instanceof \App\BusProNet\Model\Service) {
|
||||
if ($value instanceof Service) {
|
||||
return $value->id;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user