feat: refactor to cards

This commit is contained in:
Björn Fromme committed 2025-10-15 18:31:10 +02:00
1 parent ead2c092da
commit 49b7a3fe34
40 files changed
+2639 -3097

No files matched your search

@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
namespace App\Controller\Booking\Traits;
/**
* Provides participant validation error extraction for card-based booking flows.
*
* Shared between CreateStep2Controller and EditController to identify which
* participants have validation errors that should be displayed on their cards.
*/
trait ParticipantValidationTrait
{
/**
* Extracts participant indices that have validation errors.
*
* Parses form errors to identify which participants have validation issues.
* Returns an array of participant indices (e.g., [0, 2, 5]).
*
* @return array<int> Array of participant indices with errors
*/
private function extractParticipantErrorIndices($form): array
{
$errorIndices = [];
$errors = $form->getErrors(true); // Get all errors recursively
foreach ($errors as $error) {
$propertyPath = $error->getCause()?->getPropertyPath();
if (null === $propertyPath) {
continue;
}
// Property paths look like "participants[0].firstName" or "participants[1].email"
if (preg_match('/participants\[(\d+)]/', $propertyPath, $matches)) {
$index = (int) $matches[1];
$errorIndices[$index] = true; // Use array key to avoid duplicates
}
}
return array_keys($errorIndices);
}
}