fix: stop offering unbookable services in the booking edit flow

This commit is contained in:
2026-09-16 15:28:07 +02:00
parent 672fc30d7e
commit 160ebef39e
18 changed files with 1094 additions and 104 deletions
+30 -2
View File
@@ -23,6 +23,9 @@ use Psr\Log\LoggerInterface;
*/
class BookingEditDraftManager
{
/** @var list<string> */
private array $droppedServiceLabels = [];
public function __construct(
private readonly BookingEditDraftRepository $draftRepository,
private readonly EntityManagerInterface $entityManager,
@@ -32,6 +35,19 @@ class BookingEditDraftManager
) {
}
/**
* Returns the services dropped during the last applyDraftToDto() call.
*
* Reset on each call, so the caller can report them to the user. Mirrors
* BookingEditDataLoader::isDraftRestored().
*
* @return list<string>
*/
public function getDroppedServiceLabels(): array
{
return $this->droppedServiceLabels;
}
/**
* Finds an existing draft for a user and booking combination.
*
@@ -129,6 +145,9 @@ class BookingEditDraftManager
*/
public function applyDraftToDto(BookingEditDraft $draft, BookingDto $dto, Travel $travel): bool
{
$this->droppedServiceLabels = [];
$droppedServiceLabels = [];
try {
$formData = $draft->getFormData();
@@ -149,16 +168,25 @@ class BookingEditDraftManager
continue;
}
$this->participantApplier->apply(
$droppedServiceLabels = [...$droppedServiceLabels, ...$this->participantApplier->apply(
$dto,
$index,
$dto->participants[$index],
$participantData,
$travel,
);
)];
}
}
$this->droppedServiceLabels = array_values(array_unique($droppedServiceLabels));
if ([] !== $this->droppedServiceLabels) {
$this->logger->info('Dropped drafted services that are no longer bookable', [
'booking_id' => $draft->getBookingId(),
'services' => $this->droppedServiceLabels,
]);
}
$this->logger->info('Applied draft to booking DTO', [
'booking_id' => $draft->getBookingId(),
'draft_created_at' => $draft->getCreatedAt()->format('Y-m-d H:i:s'),