116 lines
3.7 KiB
PHP
116 lines
3.7 KiB
PHP
<?php
|
|
|
|
namespace App\Form\Model;
|
|
|
|
use App\BusProNet\Model\PersonalData;
|
|
use App\BusProNet\Model\Pickup;
|
|
use App\BusProNet\Model\Service;
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
|
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
|
|
|
class ParticipantData
|
|
{
|
|
public ?int $index = null;
|
|
public ?int $addressId = null;
|
|
public ?int $personId = null;
|
|
public ?string $status = null;
|
|
public bool $mutable = false;
|
|
|
|
#[Assert\NotBlank(message: 'Bitte angeben')]
|
|
public ?string $firstName = null;
|
|
|
|
#[Assert\NotBlank(message: 'Bitte angeben')]
|
|
public ?string $lastName = null;
|
|
public ?string $title = null;
|
|
public ?string $gender = null;
|
|
public ?string $nationality = null;
|
|
public ?string $height = null;
|
|
public ?string $shoeSize = null;
|
|
public ?string $weight = null;
|
|
|
|
#[Assert\NotNull(message: 'Bitte angeben')]
|
|
public ?\DateTimeImmutable $dateOfBirth = null;
|
|
|
|
#[Assert\Email(message: 'Bitte eine gültige E-Mail Adresse angeben', mode: 'strict')]
|
|
public ?string $email = null;
|
|
|
|
#[Assert\NotBlank(message: 'Bitte angeben')]
|
|
public ?string $mobile = null;
|
|
public array $courses = [];
|
|
public array $additionalServices = [];
|
|
public array $skiPass = [];
|
|
public array $board = [];
|
|
public array $rentals = [];
|
|
public ?Service $transportationServiceTo = null;
|
|
public ?Service $transportationServiceFro = null;
|
|
public ?Pickup $pickupTo = null;
|
|
public ?Pickup $pickupFro = null;
|
|
|
|
#[Assert\Callback]
|
|
public function assertBodyMeasurementsValid(ExecutionContextInterface $context): void
|
|
{
|
|
if (0 === count($this->rentals)) {
|
|
return;
|
|
}
|
|
|
|
if (empty($this->height)) {
|
|
$context->buildViolation('Bitte angeben wegen Leihmaterial')
|
|
->atPath('height')
|
|
->addViolation()
|
|
;
|
|
}
|
|
|
|
if (empty($this->shoeSize)) {
|
|
$context->buildViolation('Bitte angeben wegen Leihmaterial')
|
|
->atPath('shoeSize')
|
|
->addViolation()
|
|
;
|
|
}
|
|
|
|
if (empty($this->weight)) {
|
|
$context->buildViolation('Bitte angeben wegen Leihmaterial')
|
|
->atPath('weight')
|
|
->addViolation()
|
|
;
|
|
}
|
|
}
|
|
|
|
#[Assert\Callback]
|
|
public function assertPickupSelected(ExecutionContextInterface $context): void
|
|
{
|
|
if (null !== $this->transportationServiceTo && null === $this->pickupTo) {
|
|
$context->buildViolation('Bitte auswählen')
|
|
->atPath('pickupTo')
|
|
->addViolation()
|
|
;
|
|
}
|
|
if (null !== $this->transportationServiceFro && null === $this->pickupFro) {
|
|
$context->buildViolation('Bitte auswählen')
|
|
->atPath('pickupFro')
|
|
->addViolation()
|
|
;
|
|
}
|
|
}
|
|
|
|
public static function fromPersonalData(PersonalData $personalData): static
|
|
{
|
|
$instance = new static();
|
|
|
|
$instance->addressId = $personalData->addressId;
|
|
$instance->personId = $personalData->personId;
|
|
$instance->mutable = $personalData->mutable;
|
|
$instance->firstName = $personalData->firstName;
|
|
$instance->lastName = $personalData->name;
|
|
$instance->gender = $personalData->gender;
|
|
$instance->nationality = $personalData->nationality;
|
|
$instance->email = $personalData->communication->email;
|
|
$instance->mobile = $personalData->communication->mobile;
|
|
$instance->dateOfBirth = $personalData->dateOfBirth;
|
|
$instance->height = $personalData->height;
|
|
$instance->weight = $personalData->weight;
|
|
$instance->shoeSize = $personalData->shoeSize;
|
|
|
|
return $instance;
|
|
}
|
|
}
|