fix: don't rely on communication properties being present

This commit is contained in:
Björn Fromme
2025-03-13 17:23:52 +01:00
parent 7baea0906a
commit b88be16550
2 changed files with 11 additions and 4 deletions
@@ -2,6 +2,7 @@
namespace App\BusProNet\DataProcessor;
use App\BusProNet\Model\Communication;
use App\Form\Model\BookingData;
class BookingDataProcessor
@@ -88,8 +89,14 @@ class BookingDataProcessor
$bookingData->participants[$participant->index]->height = $participant->height;
$bookingData->participants[$participant->index]->weight = $participant->weight;
$bookingData->participants[$participant->index]->shoeSize = $participant->shoeSize;
$bookingData->participants[$participant->index]->communication->email = $participant->email;
$bookingData->participants[$participant->index]->communication->mobile = $participant->mobile;
if ($participant->email || $participant->mobile) {
if (null === $bookingData->participants[$participant->index]->communication) {
$bookingData->participants[$participant->index]->communication = new Communication();
}
$bookingData->participants[$participant->index]->communication->email = $participant->email;
$bookingData->participants[$participant->index]->communication->mobile = $participant->mobile;
}
}
// Update applicant's data with personal data of first participant
+2 -2
View File
@@ -96,8 +96,8 @@ class ParticipantData
$instance->lastName = $personalData->name;
$instance->gender = $personalData->gender;
$instance->nationality = $personalData->nationality;
$instance->email = $personalData->communication->email;
$instance->mobile = $personalData->communication->mobile;
$instance->email = $personalData->communication?->email;
$instance->mobile = $personalData->communication?->mobile;
$instance->dateOfBirth = $personalData->dateOfBirth;
$instance->height = $personalData->height;
$instance->weight = $personalData->weight;