wip: initial commit
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form\Model;
|
||||
|
||||
use App\BusProNet\Model\PersonalData;
|
||||
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;
|
||||
|
||||
#[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;
|
||||
|
||||
#[Assert\Range(notInRangeMessage: 'Bitte einen Wert im Bereich {{ min }}-{{ max }}cm angeben', min: 140, max: 210)]
|
||||
public ?string $height = null;
|
||||
|
||||
#[Assert\Range(notInRangeMessage: 'Bitte einen Wert im Bereich {{ min }}-{{ max }} angeben', min: 35, max: 49)]
|
||||
public ?string $shoeSize = null;
|
||||
|
||||
#[Assert\Range(notInRangeMessage: 'Bitte einen Wert im Bereich {{ min }}-{{ max }}kg angeben', min: 40, max: 130)]
|
||||
public ?string $weight = null;
|
||||
|
||||
#[Assert\NotNull(message: 'Bitte angeben')]
|
||||
public ?\DateTimeImmutable $dateOfBirth = null;
|
||||
|
||||
#[Assert\NotBlank(message: 'Bitte angeben')]
|
||||
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;
|
||||
|
||||
#[Assert\Callback]
|
||||
public function assertBodyMeasurements(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 Leihmaterial')
|
||||
->atPath('shoeSize')
|
||||
->addViolation()
|
||||
;
|
||||
}
|
||||
|
||||
if (empty($this->weight)) {
|
||||
$context->buildViolation('Bitte angeben Leihmaterial')
|
||||
->atPath('weight')
|
||||
->addViolation()
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
public static function fromPersonalData(PersonalData $personalData): static
|
||||
{
|
||||
$instance = new static();
|
||||
|
||||
$instance->addressId = $personalData->addressId;
|
||||
$instance->personId = $personalData->personId;
|
||||
$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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user