feat: authenticated booking

This commit is contained in:
Björn Fromme
2025-10-24 17:07:08 +02:00
parent 647a25a78f
commit b63804df88
13 changed files with 866 additions and 50 deletions
@@ -0,0 +1,76 @@
<?php
declare(strict_types=1);
namespace App\Form\Service\Condition;
use App\Form\Model\BookingDto;
use App\Form\Service\Contract\FieldConditionInterface;
/**
* Condition that determines if personal data fields should be hidden for authenticated users.
*
* When a participant is linked to an existing BPN account (has addressId and personId),
* their personal data should not be editable during the booking process. Changes to
* master personal data should only happen through the dedicated personal data management
* interface to prevent:
* - Creating duplicate customer records in BPN
* - Disconnecting bookings from the user's account
* - Data inconsistencies between booking and account data
*
* When this condition is satisfied (returns true), the template should:
* - Hide the form fields for personal data
* - Display the values as static, read-only text
*
* This follows the same pattern as bulk insurance booking.
*/
class AuthenticatedUserPersonalDataCondition implements FieldConditionInterface
{
/**
* Evaluates if personal data fields should be hidden (not editable).
*
* Returns true when the participant has both addressId and personId set,
* indicating they are linked to an existing BPN account. When true,
* personal data fields should be hidden and displayed as static text.
*
* @param BookingDto $bookingDto The current booking data
* @param int $participantIndex The index of the participant being evaluated
* @param array<string, mixed> $formData Current form data (unused)
*
* @return bool True if fields should be hidden (participant linked to BPN account)
*/
public function evaluate(BookingDto $bookingDto, int $participantIndex, array $formData): bool
{
$participant = $bookingDto->getParticipant($participantIndex);
if (null === $participant) {
return false;
}
// Hide personal data fields if participant has BPN account IDs
// (indicates prepopulation from authenticated user)
return null !== $participant->addressId && null !== $participant->personId;
}
/**
* Returns field names that this condition depends on.
*
* This condition is based on addressId/personId which are set during prepopulation
* and don't change during the form interaction, so no field dependencies.
*
* @return string[] Empty array - no field dependencies
*/
public function getDependentFields(): array
{
return [];
}
/**
* Returns a human-readable description of this condition.
*
* @return string Description of the authenticated user personal data protection logic
*/
public function getDescription(): string
{
return 'Personal data is not editable when participant is linked to BPN account (prevents duplicate records)';
}
}