wip: major refactoring

This commit is contained in:
Björn Fromme
2026-03-16 11:59:09 +01:00
parent d719b17aec
commit 11825191cf
32 changed files with 692 additions and 466 deletions
@@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
namespace App\Form\Service\Trait;
use App\Form\Model\BookingDtoInterface;
use Symfony\Component\Form\FormInterface;
/**
* Trait providing form tree traversal utilities.
*
* This trait contains common form navigation logic used across different
* form services and types. It centralizes the logic for finding root forms
* and extracting booking DTOs from form hierarchies.
*/
trait FormTraversalTrait
{
/**
* Gets the BookingDtoInterface from the root of the form tree.
*
* This helper method traverses up the form tree to find the root form
* and extracts the BookingDtoInterface data. This is shared logic used
* by both create and edit participant forms.
*
* @param FormInterface $form The form to start traversing from
*
* @return BookingDtoInterface|null The booking DTO or null if not found
*/
public function getBookingDtoFromForm(FormInterface $form): ?BookingDtoInterface
{
// Traverse up the form tree to get the root form's data
$rootForm = $form;
while ($rootForm->getParent()) {
$rootForm = $rootForm->getParent();
}
$data = $rootForm->getData();
return $data instanceof BookingDtoInterface ? $data : null;
}
}