wip: booking process

This commit is contained in:
Björn Fromme committed 2025-07-14 17:15:15 +02:00
1 parent a55e30e12d
commit bef18971c3
45 files changed
+688 -270

No files matched your search

+62
View File
@@ -1,11 +1,20 @@
<?php
declare(strict_types=1);
namespace App\BusProNet\Model;
use Symfony\Component\Serializer\Attribute\Context;
use Symfony\Component\Serializer\Attribute\Groups;
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
/**
* Represents a travel package with services, accommodation, and pricing information.
*
* This class handles travel data including dates, hotel information, available services,
* transportation options, and participant configuration. It provides methods to filter
* and retrieve services by various criteria and manage included services.
*/
class Travel
{
#[Groups(['api:list', 'api:single'])]
@@ -76,6 +85,17 @@ class Travel
#[Groups(['api:single'])]
public ?Guide $guide = null;
/**
* Retrieves additional services filtered by group and availability.
*
* Filters additional services based on the provided group(s) and optionally
* by availability. Services are sorted alphabetically by label.
*
* @param mixed $group The service group(s) to filter by
* @param bool $availableOnly Whether to include only available services
*
* @return array<Service> The filtered and sorted services array
*/
public function getAdditionalServicesByGroup(mixed $group, bool $availableOnly = true): array
{
$group = (array) $group;
@@ -91,6 +111,17 @@ class Travel
return $services;
}
/**
* Retrieves transportation services filtered by direction and availability.
*
* Filters transportation services based on travel direction and optionally
* by availability. Services are sorted by subtype.
*
* @param string $direction The travel direction to filter by
* @param bool $availableOnly Whether to include only available services
*
* @return array<Service> The filtered and sorted transportation services
*/
public function getTransportationServicesByDirection(string $direction, bool $availableOnly = true): array
{
$services = array_filter($this->transportationServices, function (Service $service) use ($direction, $availableOnly) {
@@ -106,6 +137,14 @@ class Travel
return $services;
}
/**
* Retrieves included services from selection groups.
*
* Maps selection group IDs to their corresponding services based on
* the predefined included services mapping.
*
* @return array The included services from selection groups
*/
public function getIncludedServices(): array
{
$services = [];
@@ -118,4 +157,27 @@ class Travel
return $services;
}
/**
* Retrieves rooms filtered by their IDs.
*
* Filters the rooms array to return only rooms whose IDs match
* the provided array of IDs. Returns an empty array if no matching
* rooms are found.
*
* @param array<int> $ids The array of room IDs to filter by
*
* @return array<Room> The filtered rooms array
*/
public function getRoomsByIds(array $ids): array
{
if (empty($ids)) {
return [];
}
return array_filter($this->rooms, function (Room $room) use ($ids) {
return in_array($room->id, $ids, true);
});
}
}