51 lines
1.7 KiB
PHP
51 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Form\Service\Condition;
|
|
|
|
use App\Form\Model\BookingDto;
|
|
use App\Form\Service\Contract\FieldConditionInterface;
|
|
|
|
/**
|
|
* Condition that checks whether the booking belongs to an internal agency.
|
|
*
|
|
* Internal agency bookings are made by staff on behalf of a customer, so they are exempt
|
|
* from several rules that protect customer-entered data: personal data stays editable and
|
|
* fields that are mandatory for customers may be left blank.
|
|
*
|
|
* This is the plain flag on its own. FirstParticipantReadOnlyCondition and
|
|
* PersonalDataMutabilityCondition also consult it, but combine it with further criteria.
|
|
*/
|
|
class InternalAgencyBookingCondition implements FieldConditionInterface
|
|
{
|
|
/**
|
|
* Evaluates whether the booking is an internal agency booking.
|
|
*
|
|
* @param BookingDto $bookingDto The current booking data (create or edit)
|
|
* @param int $participantIndex The index of the participant being evaluated (unused)
|
|
* @param array<string, mixed> $formData Current form data (unused)
|
|
*
|
|
* @return bool True if the booking was made by an internal agency
|
|
*/
|
|
public function evaluate(BookingDto $bookingDto, int $participantIndex, array $formData): bool
|
|
{
|
|
return $bookingDto->isInternalAgencyBooking();
|
|
}
|
|
|
|
/**
|
|
* The agency code is a property of the booking, not of any form field.
|
|
*
|
|
* @return string[] Always empty
|
|
*/
|
|
public function getDependentFields(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
public function getDescription(): string
|
|
{
|
|
return 'Checks if the booking is an internal agency booking';
|
|
}
|
|
}
|