chore: streamline property naming
This commit is contained in:
@@ -75,8 +75,8 @@ class BookingDataProcessor
|
|||||||
$servicesToReset = [
|
$servicesToReset = [
|
||||||
...$bookingData->additionalServices,
|
...$bookingData->additionalServices,
|
||||||
...$bookingData->transportationServices,
|
...$bookingData->transportationServices,
|
||||||
...$bookingData->pickupsTo,
|
...$bookingData->pickupsOutbound,
|
||||||
...$bookingData->pickupsFro,
|
...$bookingData->pickupsInbound,
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($servicesToReset as $service) {
|
foreach ($servicesToReset as $service) {
|
||||||
@@ -120,7 +120,7 @@ class BookingDataProcessor
|
|||||||
$servicesToMap = [
|
$servicesToMap = [
|
||||||
...$participant->courses,
|
...$participant->courses,
|
||||||
...$participant->additionalServices,
|
...$participant->additionalServices,
|
||||||
...$participant->skiPass,
|
...($participant->skiPass ? [$participant->skiPass] : []),
|
||||||
...$participant->board,
|
...$participant->board,
|
||||||
...$participant->rentals,
|
...$participant->rentals,
|
||||||
];
|
];
|
||||||
@@ -149,7 +149,7 @@ class BookingDataProcessor
|
|||||||
*/
|
*/
|
||||||
private function processTransportationServices(object $participant, object $bookingData, object $travelData): void
|
private function processTransportationServices(object $participant, object $bookingData, object $travelData): void
|
||||||
{
|
{
|
||||||
foreach ([$participant->transportationServiceTo, $participant->transportationServiceFro] as $service) {
|
foreach ([$participant->transportationOutbound, $participant->transportationInbound] as $service) {
|
||||||
if (false === isset($bookingData->transportationServices[$service->id])) {
|
if (false === isset($bookingData->transportationServices[$service->id])) {
|
||||||
$serviceToAdd = $travelData->transportationServices[$service->id] ?? null;
|
$serviceToAdd = $travelData->transportationServices[$service->id] ?? null;
|
||||||
if (null !== $serviceToAdd) {
|
if (null !== $serviceToAdd) {
|
||||||
@@ -172,11 +172,11 @@ class BookingDataProcessor
|
|||||||
*/
|
*/
|
||||||
private function processPickupLocations(object $participant, object $bookingData): void
|
private function processPickupLocations(object $participant, object $bookingData): void
|
||||||
{
|
{
|
||||||
if ('BUS' === $participant->transportationServiceTo->subType && null !== $selectedPickup = $participant->pickup) {
|
if ('BUS' === $participant->transportationOutbound->subType && null !== $selectedPickup = $participant->pickupOutbound) {
|
||||||
if (false === isset($bookingData->pickupsTo[$selectedPickup->id])) {
|
if (false === isset($bookingData->pickupsOutbound[$selectedPickup->id])) {
|
||||||
$bookingData->pickupsTo[$selectedPickup->id] = $selectedPickup;
|
$bookingData->pickupsOutbound[$selectedPickup->id] = $selectedPickup;
|
||||||
}
|
}
|
||||||
$bookingData->pickupsTo[$selectedPickup->id]->mapping[] = $participant->index;
|
$bookingData->pickupsOutbound[$selectedPickup->id]->mapping[] = $participant->index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,15 +202,15 @@ class BookingDataProcessor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($bookingData->pickupsTo as $pickup) {
|
foreach ($bookingData->pickupsOutbound as $pickup) {
|
||||||
if (0 === count($pickup->mapping)) {
|
if (0 === count($pickup->mapping)) {
|
||||||
unset($bookingData->pickupsTo[$pickup->id]);
|
unset($bookingData->pickupsOutbound[$pickup->id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($bookingData->pickupsFro as $pickup) {
|
foreach ($bookingData->pickupsInbound as $pickup) {
|
||||||
if (0 === count($pickup->mapping)) {
|
if (0 === count($pickup->mapping)) {
|
||||||
unset($bookingData->pickupsFro[$pickup->id]);
|
unset($bookingData->pickupsInbound[$pickup->id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -393,9 +393,9 @@ class BookingDataProcessor
|
|||||||
*/
|
*/
|
||||||
private function buildPickupPayload(array &$payload, object $bookingData): void
|
private function buildPickupPayload(array &$payload, object $bookingData): void
|
||||||
{
|
{
|
||||||
if (0 < count($bookingData->pickupsTo)) {
|
if (0 < count($bookingData->pickupsOutbound)) {
|
||||||
$payload['zustiege']['zustieg'] = [];
|
$payload['zustiege']['zustieg'] = [];
|
||||||
foreach ($bookingData->pickupsTo as $pickup) {
|
foreach ($bookingData->pickupsOutbound as $pickup) {
|
||||||
$payload['zustiege']['zustieg'][] = [
|
$payload['zustiege']['zustieg'][] = [
|
||||||
'@idzustieg' => $pickup->id,
|
'@idzustieg' => $pickup->id,
|
||||||
'@anzahl' => count($pickup->mapping),
|
'@anzahl' => count($pickup->mapping),
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ class Booking
|
|||||||
public array $transportationServices = [];
|
public array $transportationServices = [];
|
||||||
public array $additionalServices = [];
|
public array $additionalServices = [];
|
||||||
public array $rooms = [];
|
public array $rooms = [];
|
||||||
public array $pickupsTo = [];
|
public array $pickupsOutbound = [];
|
||||||
public array $pickupsFro = [];
|
public array $pickupsInbound = [];
|
||||||
public array $surcharges = [];
|
public array $surcharges = [];
|
||||||
public ?int $invoiceNumber = null;
|
public ?int $invoiceNumber = null;
|
||||||
public ?float $totalPrice = null;
|
public ?float $totalPrice = null;
|
||||||
@@ -106,7 +106,7 @@ class Booking
|
|||||||
* Retrieves transportation service for a specific participant and direction.
|
* Retrieves transportation service for a specific participant and direction.
|
||||||
*
|
*
|
||||||
* Finds the transportation service that matches the participant index
|
* Finds the transportation service that matches the participant index
|
||||||
* and travel direction (e.g., 'H' for outbound, 'R' for return).
|
* and travel direction (e.g., 'H' for outbound, 'R' for inbound).
|
||||||
*
|
*
|
||||||
* @param int $participantIndex The participant index to search for
|
* @param int $participantIndex The participant index to search for
|
||||||
* @param string $direction The travel direction ('H' or 'R')
|
* @param string $direction The travel direction ('H' or 'R')
|
||||||
@@ -141,7 +141,7 @@ class Booking
|
|||||||
*/
|
*/
|
||||||
public function getPickupForParticipant(int $participantIndex): ?Pickup
|
public function getPickupForParticipant(int $participantIndex): ?Pickup
|
||||||
{
|
{
|
||||||
foreach ($this->pickupsTo as $pickup) {
|
foreach ($this->pickupsOutbound as $pickup) {
|
||||||
if (in_array($participantIndex, $pickup->mapping)) {
|
if (in_array($participantIndex, $pickup->mapping)) {
|
||||||
return $pickup;
|
return $pickup;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,10 +63,10 @@ class Travel
|
|||||||
public bool $transportationServicesMutable = true;
|
public bool $transportationServicesMutable = true;
|
||||||
|
|
||||||
#[Groups(['api:single'])]
|
#[Groups(['api:single'])]
|
||||||
public array $pickupsTo = [];
|
public array $pickupsOutbound = [];
|
||||||
|
|
||||||
#[Groups(['api:single'])]
|
#[Groups(['api:single'])]
|
||||||
public array $pickupsFro = [];
|
public array $pickupsInbound = [];
|
||||||
|
|
||||||
#[Groups(['api:single'])]
|
#[Groups(['api:single'])]
|
||||||
public bool $pickupsMutable = true;
|
public bool $pickupsMutable = true;
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class PickupLoader extends AbstractLoader
|
|||||||
|
|
||||||
public function patchPickupsDetails(Travel $travel): void
|
public function patchPickupsDetails(Travel $travel): void
|
||||||
{
|
{
|
||||||
foreach ($travel->pickupsTo as $pickupId => $pickup) {
|
foreach ($travel->pickupsOutbound as $pickupId => $pickup) {
|
||||||
$pickupData = $this->loadById($pickupId);
|
$pickupData = $this->loadById($pickupId);
|
||||||
|
|
||||||
$pickup->code = $pickupData->code;
|
$pickup->code = $pickupData->code;
|
||||||
@@ -69,7 +69,7 @@ class PickupLoader extends AbstractLoader
|
|||||||
$pickup->city = $pickupData->city;
|
$pickup->city = $pickupData->city;
|
||||||
$pickup->street = $pickupData->street;
|
$pickup->street = $pickupData->street;
|
||||||
}
|
}
|
||||||
foreach ($travel->pickupsFro as $pickupId => $pickup) {
|
foreach ($travel->pickupsInbound as $pickupId => $pickup) {
|
||||||
$pickupData = $this->loadById($pickupId);
|
$pickupData = $this->loadById($pickupId);
|
||||||
|
|
||||||
$pickup->code = $pickupData->code;
|
$pickup->code = $pickupData->code;
|
||||||
|
|||||||
@@ -89,11 +89,11 @@ class BookingParser extends AbstractParser
|
|||||||
|
|
||||||
$pickupsData = $node->filterXPath('//zustiege/zustieg');
|
$pickupsData = $node->filterXPath('//zustiege/zustieg');
|
||||||
if (0 < $pickupsData->count()) {
|
if (0 < $pickupsData->count()) {
|
||||||
$booking->pickupsTo = $this->pickupsParser->parse($pickupsData);
|
$booking->pickupsOutbound = $this->pickupsParser->parse($pickupsData);
|
||||||
}
|
}
|
||||||
$pickupsData = $node->filterXPath('//zustiege_rueck/zustieg_rueck');
|
$pickupsData = $node->filterXPath('//zustiege_rueck/zustieg_rueck');
|
||||||
if (0 < $pickupsData->count()) {
|
if (0 < $pickupsData->count()) {
|
||||||
$booking->pickupsFro = $this->pickupsParser->parse($pickupsData);
|
$booking->pickupsInbound = $this->pickupsParser->parse($pickupsData);
|
||||||
}
|
}
|
||||||
|
|
||||||
$surchargesData = $node->filterXPath('//zuschlaege/zuschlag');
|
$surchargesData = $node->filterXPath('//zuschlaege/zuschlag');
|
||||||
|
|||||||
@@ -61,8 +61,8 @@ class TravelParser extends AbstractParser
|
|||||||
$travel->transportationServices = $this
|
$travel->transportationServices = $this
|
||||||
->getTransportationServices($node->filterXPath('//lei_befoerderung/leistung'));
|
->getTransportationServices($node->filterXPath('//lei_befoerderung/leistung'));
|
||||||
$travel->rooms = $this->getRooms($hotelNode);
|
$travel->rooms = $this->getRooms($hotelNode);
|
||||||
$travel->pickupsTo = $this->getPickups($node->filterXPath('//zustiege/zustieg'), $dateFrom);
|
$travel->pickupsOutbound = $this->getPickups($node->filterXPath('//zustiege/zustieg'), $dateFrom);
|
||||||
$travel->pickupsFro = $this->getPickups($node->filterXPath('//zustiege_rueck/zustieg_rueck'));
|
$travel->pickupsInbound = $this->getPickups($node->filterXPath('//zustiege_rueck/zustieg_rueck'));
|
||||||
$travel->guide = $this->getGuide($node);
|
$travel->guide = $this->getGuide($node);
|
||||||
|
|
||||||
return $travel;
|
return $travel;
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ class BookingEditParticipantType extends AbstractType
|
|||||||
return $attributes;
|
return $attributes;
|
||||||
};
|
};
|
||||||
$form
|
$form
|
||||||
->add('transportationServiceTo', ChoiceType::class, [
|
->add('transportationOutbound', ChoiceType::class, [
|
||||||
...$commonChoiceFieldOptions,
|
...$commonChoiceFieldOptions,
|
||||||
'label' => 'Anreise',
|
'label' => 'Anreise',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
@@ -222,7 +222,7 @@ class BookingEditParticipantType extends AbstractType
|
|||||||
'choices' => $options['selectable_transportation_services_to'],
|
'choices' => $options['selectable_transportation_services_to'],
|
||||||
'choice_attr' => $transportationChoiceAttributes,
|
'choice_attr' => $transportationChoiceAttributes,
|
||||||
])
|
])
|
||||||
->add('transportationServiceFro', ChoiceType::class, [
|
->add('transportationInbound', ChoiceType::class, [
|
||||||
...$commonChoiceFieldOptions,
|
...$commonChoiceFieldOptions,
|
||||||
'label' => 'Rückreise',
|
'label' => 'Rückreise',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
@@ -232,7 +232,7 @@ class BookingEditParticipantType extends AbstractType
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
// Pickup
|
// Pickup
|
||||||
$form->add('pickup', ChoiceType::class, [
|
$form->add('pickupOutbound', ChoiceType::class, [
|
||||||
'label' => 'Zustieg',
|
'label' => 'Zustieg',
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
@@ -319,12 +319,12 @@ class BookingEditParticipantType extends AbstractType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$transportationId = $data['transportationServiceTo'] ?? null;
|
$transportationId = $data['transportationOutbound'] ?? null;
|
||||||
$transportation = $options['travel']->pickups[$transportationId] ?? null;
|
$transportation = $options['travel']->pickups[$transportationId] ?? null;
|
||||||
|
|
||||||
if (null !== $transportation && 'PKW' === $transportation->subType) {
|
if (null !== $transportation && 'PKW' === $transportation->subType) {
|
||||||
$form->remove('pickup');
|
$form->remove('pickupOutbound');
|
||||||
unset($data['pickup']);
|
unset($data['pickupOutbound']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// forcibly select mandatory services that potentially have been disabled in PRE_SET_DATA
|
// forcibly select mandatory services that potentially have been disabled in PRE_SET_DATA
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class BookingEditType extends AbstractType
|
|||||||
->getTransportationServicesByDirection('HIN', false),
|
->getTransportationServicesByDirection('HIN', false),
|
||||||
'selectable_transportation_services_fro' => $travelData
|
'selectable_transportation_services_fro' => $travelData
|
||||||
->getTransportationServicesByDirection('RUECK', false),
|
->getTransportationServicesByDirection('RUECK', false),
|
||||||
'selectable_pickups' => $travelData->pickupsTo,
|
'selectable_pickups' => $travelData->pickupsOutbound,
|
||||||
'personal_data_mutable' => $travelData->participantDataMutable,
|
'personal_data_mutable' => $travelData->participantDataMutable,
|
||||||
'additional_services_mutable' => $travelData->additionalServicesMutable,
|
'additional_services_mutable' => $travelData->additionalServicesMutable,
|
||||||
'transportation_services_mutable' => $travelData->transportationServicesMutable,
|
'transportation_services_mutable' => $travelData->transportationServicesMutable,
|
||||||
|
|||||||
@@ -58,14 +58,9 @@ class BookingEditDto implements BookingDtoInterface
|
|||||||
$participantData->transportationOutbound = $outboundTransportation;
|
$participantData->transportationOutbound = $outboundTransportation;
|
||||||
$participantData->transportationInbound = $inboundTransportation;
|
$participantData->transportationInbound = $inboundTransportation;
|
||||||
|
|
||||||
// Backward compatibility: also set deprecated properties
|
|
||||||
$participantData->transportationServiceTo = $outboundTransportation;
|
|
||||||
$participantData->transportationServiceFro = $inboundTransportation;
|
|
||||||
|
|
||||||
// Pickup handling (currently only supports outbound pickup)
|
// Pickup handling (currently only supports outbound pickup)
|
||||||
$pickupOutbound = $booking->getPickupForParticipant($index);
|
$pickupOutbound = $booking->getPickupForParticipant($index);
|
||||||
$participantData->pickupOutbound = $pickupOutbound;
|
$participantData->pickupOutbound = $pickupOutbound;
|
||||||
$participantData->pickup = $pickupOutbound; // Backward compatibility
|
|
||||||
|
|
||||||
$instance->participants[$index] = $participantData;
|
$instance->participants[$index] = $participantData;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,11 +71,6 @@ class ParticipantDto
|
|||||||
// License plate for participants with parking (optional, visible only when parking is selected)
|
// License plate for participants with parking (optional, visible only when parking is selected)
|
||||||
public ?string $licensePlate = null;
|
public ?string $licensePlate = null;
|
||||||
|
|
||||||
// Deprecated properties for backward compatibility - will be removed in future version
|
|
||||||
public ?Service $transportationServiceTo = null;
|
|
||||||
public ?Service $transportationServiceFro = null;
|
|
||||||
public ?Pickup $pickup = null;
|
|
||||||
|
|
||||||
public static function fromPersonalData(PersonalData $personalData): static
|
public static function fromPersonalData(PersonalData $personalData): static
|
||||||
{
|
{
|
||||||
$instance = new static();
|
$instance = new static();
|
||||||
@@ -98,6 +93,11 @@ class ParticipantDto
|
|||||||
return $instance;
|
return $instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isApplicant(): bool
|
||||||
|
{
|
||||||
|
return 0 === $this->index;
|
||||||
|
}
|
||||||
|
|
||||||
public function isCanceled(): bool
|
public function isCanceled(): bool
|
||||||
{
|
{
|
||||||
return 'S' === $this->status;
|
return 'S' === $this->status;
|
||||||
|
|||||||
@@ -328,7 +328,7 @@ class ParticipantFieldOptionsProvider extends AbstractFieldOptionsProvider
|
|||||||
// Outbound Pickup (conditional - only shown when outbound transportation is bus)
|
// Outbound Pickup (conditional - only shown when outbound transportation is bus)
|
||||||
$this->fieldOptionProviders['pickupOutbound'] = fn (BookingDtoInterface $bookingDto, int $participantIndex, array $options = []) => [
|
$this->fieldOptionProviders['pickupOutbound'] = fn (BookingDtoInterface $bookingDto, int $participantIndex, array $options = []) => [
|
||||||
'label' => 'Zustieg Hinfahrt',
|
'label' => 'Zustieg Hinfahrt',
|
||||||
'choices' => $bookingDto->travel->pickupsTo,
|
'choices' => $bookingDto->travel->pickupsOutbound,
|
||||||
'choice_label' => fn (?Pickup $pickup) => $this->formatPickupLabelWithPrice($pickup),
|
'choice_label' => fn (?Pickup $pickup) => $this->formatPickupLabelWithPrice($pickup),
|
||||||
'choice_value' => 'id',
|
'choice_value' => 'id',
|
||||||
'expanded' => false, // Dropdown for pickups
|
'expanded' => false, // Dropdown for pickups
|
||||||
@@ -340,7 +340,7 @@ class ParticipantFieldOptionsProvider extends AbstractFieldOptionsProvider
|
|||||||
// Inbound Pickup (conditional - only shown when inbound transportation is bus)
|
// Inbound Pickup (conditional - only shown when inbound transportation is bus)
|
||||||
$this->fieldOptionProviders['pickupInbound'] = fn (BookingDtoInterface $bookingDto, int $participantIndex, array $options = []) => [
|
$this->fieldOptionProviders['pickupInbound'] = fn (BookingDtoInterface $bookingDto, int $participantIndex, array $options = []) => [
|
||||||
'label' => 'Ausstieg Rückfahrt',
|
'label' => 'Ausstieg Rückfahrt',
|
||||||
'choices' => $bookingDto->travel->pickupsFro,
|
'choices' => $bookingDto->travel->pickupsInbound,
|
||||||
'choice_label' => fn (?Pickup $pickup) => $this->formatPickupLabelWithPrice($pickup),
|
'choice_label' => fn (?Pickup $pickup) => $this->formatPickupLabelWithPrice($pickup),
|
||||||
'choice_value' => 'id',
|
'choice_value' => 'id',
|
||||||
'expanded' => false,
|
'expanded' => false,
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class ParticipantPickupInboundFieldHandler extends AbstractParticipantFieldHandl
|
|||||||
// Validate pickup selection against available inbound pickups
|
// Validate pickup selection against available inbound pickups
|
||||||
$validSelection = null;
|
$validSelection = null;
|
||||||
if (null !== $selectedPickup) {
|
if (null !== $selectedPickup) {
|
||||||
$validSelection = $this->findValidPickup($selectedPickup, $bookingDto->travel->pickupsFro);
|
$validSelection = $this->findValidPickup($selectedPickup, $bookingDto->travel->pickupsInbound);
|
||||||
}
|
}
|
||||||
|
|
||||||
$participant->pickupInbound = $validSelection;
|
$participant->pickupInbound = $validSelection;
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ class ParticipantPickupOutboundFieldHandler extends AbstractParticipantFieldHand
|
|||||||
// Validate pickup selection against available outbound pickups
|
// Validate pickup selection against available outbound pickups
|
||||||
$validSelection = null;
|
$validSelection = null;
|
||||||
if (null !== $selectedPickup) {
|
if (null !== $selectedPickup) {
|
||||||
$validSelection = $this->findValidPickup($selectedPickup, $bookingDto->travel->pickupsTo);
|
$validSelection = $this->findValidPickup($selectedPickup, $bookingDto->travel->pickupsOutbound);
|
||||||
}
|
}
|
||||||
|
|
||||||
$participant->pickupOutbound = $validSelection;
|
$participant->pickupOutbound = $validSelection;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use App\Form\Service\Abstract\AbstractParticipantFieldHandler;
|
|||||||
*
|
*
|
||||||
* This handler manages rental equipment selections for participants in the booking
|
* This handler manages rental equipment selections for participants in the booking
|
||||||
* creation process. It processes the rentals field from form submissions,
|
* creation process. It processes the rentals field from form submissions,
|
||||||
* filters out age-inappropriate options and duration-inappropriate options, and
|
* filters out age-inappropriate options and duration-inappropriate options, and
|
||||||
* updates the participant DTO with only valid selections.
|
* updates the participant DTO with only valid selections.
|
||||||
*
|
*
|
||||||
* Dependencies: dateOfBirth (for age evaluation) and skiPass (for duration filtering)
|
* Dependencies: dateOfBirth (for age evaluation) and skiPass (for duration filtering)
|
||||||
@@ -68,7 +68,7 @@ class ParticipantRentalsFieldHandler extends AbstractParticipantFieldHandler
|
|||||||
if (null === $participant->skiPass) {
|
if (null === $participant->skiPass) {
|
||||||
// No skipass selected = clear all rental selections
|
// No skipass selected = clear all rental selections
|
||||||
$participant->rentals = [];
|
$participant->rentals = [];
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -511,6 +511,39 @@ class TravelDataService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch availability data with short-term caching.
|
||||||
|
*
|
||||||
|
* Retrieves availability information from the API with caching to reduce
|
||||||
|
* API calls during booking form interactions. Uses a short TTL to ensure
|
||||||
|
* reasonably fresh data while avoiding excessive API requests.
|
||||||
|
*
|
||||||
|
* @param int $dateId The travel date ID for API call
|
||||||
|
* @param int $ttl Cache TTL in seconds (default: 60 seconds)
|
||||||
|
*
|
||||||
|
* @return BaseData|null The availability data or null if not available or error occurred
|
||||||
|
*/
|
||||||
|
public function getAvailabilityDataCached(int $dateId, int $ttl = 60): ?BaseData
|
||||||
|
{
|
||||||
|
$cacheKey = sprintf('availability_%d', $dateId);
|
||||||
|
|
||||||
|
try {
|
||||||
|
return $this->cache->get($cacheKey, function (ItemInterface $item) use ($dateId, $ttl) {
|
||||||
|
$item->expiresAfter($ttl);
|
||||||
|
|
||||||
|
return $this->getAvailabilityData($dateId);
|
||||||
|
});
|
||||||
|
} catch (InvalidArgumentException $e) {
|
||||||
|
$this->logger->error('Cache error in getAvailabilityDataCached', [
|
||||||
|
'dateId' => $dateId,
|
||||||
|
'error' => $e->getMessage(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Fallback to direct API call
|
||||||
|
return $this->getAvailabilityData($dateId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply availability data to travel services.
|
* Apply availability data to travel services.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class ParticipantValidator extends ConstraintValidator
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (['transportationServiceTo', 'transportationServiceFro'] as $property) {
|
foreach (['transportationOutbound', 'transportationInbound'] as $property) {
|
||||||
if (null === $participant->{$property}) {
|
if (null === $participant->{$property}) {
|
||||||
$this->context->buildViolation('Bitte angeben')
|
$this->context->buildViolation('Bitte angeben')
|
||||||
->atPath($property)
|
->atPath($property)
|
||||||
@@ -54,12 +54,12 @@ class ParticipantValidator extends ConstraintValidator
|
|||||||
public function assertPickupSelected(ParticipantDto $participant): void
|
public function assertPickupSelected(ParticipantDto $participant): void
|
||||||
{
|
{
|
||||||
if (
|
if (
|
||||||
null !== $participant->transportationServiceTo
|
null !== $participant->transportationOutbound
|
||||||
&& 'BUS' === $participant->transportationServiceTo->subType
|
&& 'BUS' === $participant->transportationOutbound->subType
|
||||||
&& null === $participant->pickup
|
&& null === $participant->pickupOutbound
|
||||||
) {
|
) {
|
||||||
$this->context->buildViolation('Bitte auswählen')
|
$this->context->buildViolation('Bitte auswählen')
|
||||||
->atPath('pickup')
|
->atPath('pickupOutbound')
|
||||||
->addViolation()
|
->addViolation()
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -224,15 +224,15 @@
|
|||||||
Hin-/Rückreise
|
Hin-/Rückreise
|
||||||
</h3>
|
</h3>
|
||||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-x-8 gap-y-4">
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-x-8 gap-y-4">
|
||||||
<div class="space-y-2" {{ stimulus_controller('select-toggle', { 'show': ['BUS'], 'visible': participant.transportationServiceTo is not null and participant.transportationServiceTo.subType == 'BUS' }, { 'hidden': 'hidden' }) }}>
|
<div class="space-y-2" {{ stimulus_controller('select-toggle', { 'show': ['BUS'], 'visible': participant.transportationOutbound is not null and participant.transportationOutbound.subType == 'BUS' }, { 'hidden': 'hidden' }) }}>
|
||||||
{{ form_row(child.transportationServiceTo) }}
|
{{ form_row(child.transportationOutbound) }}
|
||||||
{% if child.pickup is defined %}
|
{% if child.pickupOutbound is defined %}
|
||||||
<div {{ stimulus_target('select-toggle', 'container') }}>
|
<div {{ stimulus_target('select-toggle', 'container') }}>
|
||||||
{{ form_row(child.pickup) }}
|
{{ form_row(child.pickupOutbound) }}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{{ form_row(child.transportationServiceFro) }}
|
{{ form_row(child.transportationInbound) }}
|
||||||
</div>
|
</div>
|
||||||
{% if not travelData.transportationServicesMutable %}
|
{% if not travelData.transportationServicesMutable %}
|
||||||
<div class="absolute inset-0 cursor-not-allowed"></div>
|
<div class="absolute inset-0 cursor-not-allowed"></div>
|
||||||
|
|||||||
@@ -248,8 +248,8 @@ class BookingDataProcessorTest extends TestCase
|
|||||||
$formData = $this->createCompleteFormData();
|
$formData = $this->createCompleteFormData();
|
||||||
|
|
||||||
$participant = $formData->participants[0];
|
$participant = $formData->participants[0];
|
||||||
$participant->transportationServiceTo = $this->createMockService(1);
|
$participant->transportationOutbound = $this->createMockService(1);
|
||||||
$participant->transportationServiceFro = $this->createMockService(2);
|
$participant->transportationInbound = $this->createMockService(2);
|
||||||
|
|
||||||
return $formData;
|
return $formData;
|
||||||
}
|
}
|
||||||
@@ -261,8 +261,8 @@ class BookingDataProcessorTest extends TestCase
|
|||||||
$participant = $formData->participants[0];
|
$participant = $formData->participants[0];
|
||||||
$busService = $this->createMockService(1);
|
$busService = $this->createMockService(1);
|
||||||
$busService->subType = 'BUS';
|
$busService->subType = 'BUS';
|
||||||
$participant->transportationServiceTo = $busService;
|
$participant->transportationOutbound = $busService;
|
||||||
$participant->pickup = $this->createMockPickup(1);
|
$participant->pickupOutbound = $this->createMockPickup(1);
|
||||||
|
|
||||||
return $formData;
|
return $formData;
|
||||||
}
|
}
|
||||||
@@ -274,7 +274,7 @@ class BookingDataProcessorTest extends TestCase
|
|||||||
$participant = $formData->participants[0];
|
$participant = $formData->participants[0];
|
||||||
$trainService = $this->createMockService(1);
|
$trainService = $this->createMockService(1);
|
||||||
$trainService->subType = 'TRAIN';
|
$trainService->subType = 'TRAIN';
|
||||||
$participant->transportationServiceTo = $trainService;
|
$participant->transportationOutbound = $trainService;
|
||||||
|
|
||||||
return $formData;
|
return $formData;
|
||||||
}
|
}
|
||||||
@@ -387,7 +387,7 @@ class BookingDataProcessorTest extends TestCase
|
|||||||
private function createFormDataWithoutPickups(): BookingEditDto
|
private function createFormDataWithoutPickups(): BookingEditDto
|
||||||
{
|
{
|
||||||
$formData = $this->createCompleteFormData();
|
$formData = $this->createCompleteFormData();
|
||||||
$formData->booking->pickupsTo = [];
|
$formData->booking->pickupsOutbound = [];
|
||||||
|
|
||||||
return $formData;
|
return $formData;
|
||||||
}
|
}
|
||||||
@@ -405,8 +405,8 @@ class BookingDataProcessorTest extends TestCase
|
|||||||
$booking->paymentType = 'CC';
|
$booking->paymentType = 'CC';
|
||||||
$booking->additionalServices = [];
|
$booking->additionalServices = [];
|
||||||
$booking->transportationServices = [];
|
$booking->transportationServices = [];
|
||||||
$booking->pickupsTo = [];
|
$booking->pickupsOutbound = [];
|
||||||
$booking->pickupsFro = [];
|
$booking->pickupsInbound = [];
|
||||||
$booking->participants = [
|
$booking->participants = [
|
||||||
$this->createMockPersonalData('Participant0'),
|
$this->createMockPersonalData('Participant0'),
|
||||||
$this->createMockPersonalData('Participant1'),
|
$this->createMockPersonalData('Participant1'),
|
||||||
@@ -451,12 +451,12 @@ class BookingDataProcessorTest extends TestCase
|
|||||||
$participant->mobile = null;
|
$participant->mobile = null;
|
||||||
$participant->courses = [];
|
$participant->courses = [];
|
||||||
$participant->additionalServices = [];
|
$participant->additionalServices = [];
|
||||||
$participant->skiPass = [];
|
$participant->skiPass = null;
|
||||||
$participant->board = [];
|
$participant->board = [];
|
||||||
$participant->rentals = [];
|
$participant->rentals = [];
|
||||||
$participant->transportationServiceTo = $this->createMockService(1);
|
$participant->transportationOutbound = $this->createMockService(1);
|
||||||
$participant->transportationServiceFro = $this->createMockService(2);
|
$participant->transportationInbound = $this->createMockService(2);
|
||||||
$participant->pickup = null;
|
$participant->pickupOutbound = null;
|
||||||
|
|
||||||
return $participant;
|
return $participant;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user