fix: ensure nationality is assigned when editing booking data
This commit is contained in:
@@ -7,6 +7,7 @@ namespace App\BusProNet\DataProcessor;
|
||||
use App\BusProNet\Model\Address;
|
||||
use App\BusProNet\Model\Booking;
|
||||
use App\BusProNet\Model\Communication;
|
||||
use App\BusProNet\Model\PersonalData;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
|
||||
/**
|
||||
@@ -50,6 +51,8 @@ class PersonalDataSynchronizer
|
||||
$bookingData->participants[$participant->index]->dateOfBirth = $participant->dateOfBirth;
|
||||
$bookingData->participants[$participant->index]->gender = $participant->gender;
|
||||
$bookingData->participants[$participant->index]->nationality = $participant->nationality;
|
||||
|
||||
$this->fillMissingParticipantFields($bookingData->participants[$participant->index]);
|
||||
$bookingData->participants[$participant->index]->height = $participant->height;
|
||||
$bookingData->participants[$participant->index]->weight = $participant->weight;
|
||||
$bookingData->participants[$participant->index]->shoeSize = $participant->shoeSize;
|
||||
@@ -117,4 +120,19 @@ class PersonalDataSynchronizer
|
||||
$applicant->communication->mobile = '12345';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills missing mandatory fields on a participant.
|
||||
*
|
||||
* Ensures mandatory fields have sensible defaults before submission to the
|
||||
* BPN API. Currently handles nationality which defaults to 'D' (German).
|
||||
*
|
||||
* @param \App\BusProNet\Model\PersonalData $participant The participant to fill defaults for
|
||||
*/
|
||||
private function fillMissingParticipantFields(PersonalData $participant): void
|
||||
{
|
||||
if (null === $participant->nationality || '' === $participant->nationality) {
|
||||
$participant->nationality = 'D';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,9 @@ class BookingEditParticipantType extends AbstractType
|
||||
->add('nationality', CountryType::class, $this->mergeFieldState([
|
||||
'label' => 'Nationalität',
|
||||
'property' => 'nationality',
|
||||
'required' => true,
|
||||
'preferred_choices' => ['D', 'A', 'CH'],
|
||||
'empty_data' => 'D',
|
||||
], $getState('nationality')))
|
||||
->add('email', EmailType::class, $this->mergeFieldState([
|
||||
'label' => 'E-Mail',
|
||||
|
||||
Reference in New Issue
Block a user