chore: simplify parameter handling
This commit is contained in:
@@ -18,7 +18,6 @@ use App\Service\ParticipantPrepopulationService;
|
|||||||
use App\Service\RoomAssignmentService;
|
use App\Service\RoomAssignmentService;
|
||||||
use App\Service\TravelDataService;
|
use App\Service\TravelDataService;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\DependencyInjection\Attribute\Autowire;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
@@ -36,10 +35,6 @@ class Step2Controller extends AbstractController
|
|||||||
use HxTrait;
|
use HxTrait;
|
||||||
use ParticipantCardFlowTrait;
|
use ParticipantCardFlowTrait;
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array<string, string> $heightChoices
|
|
||||||
* @param array<string, string> $weightChoices
|
|
||||||
*/
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly BookingService $bookingService,
|
private readonly BookingService $bookingService,
|
||||||
private readonly BookingSummaryDataService $summaryDataService,
|
private readonly BookingSummaryDataService $summaryDataService,
|
||||||
@@ -48,43 +43,9 @@ class Step2Controller extends AbstractController
|
|||||||
private readonly ParticipantCardDataService $participantCardService,
|
private readonly ParticipantCardDataService $participantCardService,
|
||||||
private readonly ParticipantFieldOptionsProvider $fieldOptionsProvider,
|
private readonly ParticipantFieldOptionsProvider $fieldOptionsProvider,
|
||||||
private readonly ParticipantPrepopulationService $prepopulationService,
|
private readonly ParticipantPrepopulationService $prepopulationService,
|
||||||
#[Autowire(param: 'body_dimensions.height_choices')]
|
|
||||||
private readonly array $heightChoices,
|
|
||||||
#[Autowire(param: 'body_dimensions.weight_choices')]
|
|
||||||
private readonly array $weightChoices,
|
|
||||||
#[Autowire(param: 'body_dimensions.shoe_size_min')]
|
|
||||||
private readonly int $shoeSizeMin,
|
|
||||||
#[Autowire(param: 'body_dimensions.shoe_size_max')]
|
|
||||||
private readonly int $shoeSizeMax,
|
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, string>
|
|
||||||
*/
|
|
||||||
private function getHeightChoices(): array
|
|
||||||
{
|
|
||||||
return $this->heightChoices;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, string>
|
|
||||||
*/
|
|
||||||
private function getWeightChoices(): array
|
|
||||||
{
|
|
||||||
return $this->weightChoices;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getShoeSizeMin(): int
|
|
||||||
{
|
|
||||||
return $this->shoeSizeMin;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getShoeSizeMax(): int
|
|
||||||
{
|
|
||||||
return $this->shoeSizeMax;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display card grid for all participants.
|
* Display card grid for all participants.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ use App\Service\ParticipantCardDataService;
|
|||||||
use App\Service\TravelDataService;
|
use App\Service\TravelDataService;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\DependencyInjection\Attribute\Autowire;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
@@ -46,10 +45,6 @@ class IndexController extends AbstractController
|
|||||||
use HxTrait;
|
use HxTrait;
|
||||||
use Traits\ParticipantCardFlowTrait;
|
use Traits\ParticipantCardFlowTrait;
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array<string, string> $heightChoices
|
|
||||||
* @param array<string, string> $weightChoices
|
|
||||||
*/
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly ApiClient $apiClient,
|
private readonly ApiClient $apiClient,
|
||||||
private readonly BookingEditDataLoaderService $dataLoader,
|
private readonly BookingEditDataLoaderService $dataLoader,
|
||||||
@@ -60,43 +55,9 @@ class IndexController extends AbstractController
|
|||||||
private readonly ParticipantCardDataService $participantCardService,
|
private readonly ParticipantCardDataService $participantCardService,
|
||||||
private readonly Crypt $crypt,
|
private readonly Crypt $crypt,
|
||||||
private readonly LoggerInterface $logger,
|
private readonly LoggerInterface $logger,
|
||||||
#[Autowire(param: 'body_dimensions.height_choices')]
|
|
||||||
private readonly array $heightChoices,
|
|
||||||
#[Autowire(param: 'body_dimensions.weight_choices')]
|
|
||||||
private readonly array $weightChoices,
|
|
||||||
#[Autowire(param: 'body_dimensions.shoe_size_min')]
|
|
||||||
private readonly int $shoeSizeMin,
|
|
||||||
#[Autowire(param: 'body_dimensions.shoe_size_max')]
|
|
||||||
private readonly int $shoeSizeMax,
|
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, string>
|
|
||||||
*/
|
|
||||||
private function getHeightChoices(): array
|
|
||||||
{
|
|
||||||
return $this->heightChoices;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, string>
|
|
||||||
*/
|
|
||||||
private function getWeightChoices(): array
|
|
||||||
{
|
|
||||||
return $this->weightChoices;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getShoeSizeMin(): int
|
|
||||||
{
|
|
||||||
return $this->shoeSizeMin;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getShoeSizeMax(): int
|
|
||||||
{
|
|
||||||
return $this->shoeSizeMax;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display participant cards overview.
|
* Display participant cards overview.
|
||||||
*/
|
*/
|
||||||
@@ -220,10 +181,10 @@ class IndexController extends AbstractController
|
|||||||
// Create form for participant with booking context
|
// Create form for participant with booking context
|
||||||
$form = $this->createForm(BookingParticipantType::class, $wrapper, [
|
$form = $this->createForm(BookingParticipantType::class, $wrapper, [
|
||||||
'booking_context' => $bookingDto,
|
'booking_context' => $bookingDto,
|
||||||
'height_choices' => $this->heightChoices,
|
'height_choices' => $this->getParameter('body_dimensions.height_choices'),
|
||||||
'weight_choices' => $this->weightChoices,
|
'weight_choices' => $this->getParameter('body_dimensions.weight_choices'),
|
||||||
'shoe_size_min' => $this->shoeSizeMin,
|
'shoe_size_min' => $this->getParameter('body_dimensions.shoe_size_min'),
|
||||||
'shoe_size_max' => $this->shoeSizeMax,
|
'shoe_size_max' => $this->getParameter('body_dimensions.shoe_size_max'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
@@ -307,10 +268,10 @@ class IndexController extends AbstractController
|
|||||||
$form = $this->createForm(BookingParticipantType::class, $wrapper, [
|
$form = $this->createForm(BookingParticipantType::class, $wrapper, [
|
||||||
'booking_context' => $bookingDto,
|
'booking_context' => $bookingDto,
|
||||||
'validation_groups' => false,
|
'validation_groups' => false,
|
||||||
'height_choices' => $this->heightChoices,
|
'height_choices' => $this->getParameter('body_dimensions.height_choices'),
|
||||||
'weight_choices' => $this->weightChoices,
|
'weight_choices' => $this->getParameter('body_dimensions.weight_choices'),
|
||||||
'shoe_size_min' => $this->shoeSizeMin,
|
'shoe_size_min' => $this->getParameter('body_dimensions.shoe_size_min'),
|
||||||
'shoe_size_max' => $this->shoeSizeMax,
|
'shoe_size_max' => $this->getParameter('body_dimensions.shoe_size_max'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|||||||
@@ -74,29 +74,15 @@ trait ParticipantCardFlowTrait
|
|||||||
// Merge default options with provided options and body dimensions
|
// Merge default options with provided options and body dimensions
|
||||||
$formOptions = array_merge([
|
$formOptions = array_merge([
|
||||||
'booking_context' => $bookingDto,
|
'booking_context' => $bookingDto,
|
||||||
'height_choices' => $this->getHeightChoices(),
|
'height_choices' => $this->getParameter('body_dimensions.height_choices'),
|
||||||
'weight_choices' => $this->getWeightChoices(),
|
'weight_choices' => $this->getParameter('body_dimensions.weight_choices'),
|
||||||
'shoe_size_min' => $this->getShoeSizeMin(),
|
'shoe_size_min' => $this->getParameter('body_dimensions.shoe_size_min'),
|
||||||
'shoe_size_max' => $this->getShoeSizeMax(),
|
'shoe_size_max' => $this->getParameter('body_dimensions.shoe_size_max'),
|
||||||
], $options);
|
], $options);
|
||||||
|
|
||||||
return $this->createForm(BookingParticipantType::class, $wrapper, $formOptions);
|
return $this->createForm(BookingParticipantType::class, $wrapper, $formOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, string>
|
|
||||||
*/
|
|
||||||
abstract private function getHeightChoices(): array;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<string, string>
|
|
||||||
*/
|
|
||||||
abstract private function getWeightChoices(): array;
|
|
||||||
|
|
||||||
abstract private function getShoeSizeMin(): int;
|
|
||||||
|
|
||||||
abstract private function getShoeSizeMax(): int;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Collects notifications from all participants and clears them from DTOs.
|
* Collects notifications from all participants and clears them from DTOs.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user