57 lines
1.4 KiB
PHP
57 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Model;
|
|
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
|
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
|
|
|
class DriverLicenseDeclarationDto
|
|
{
|
|
#[Assert\NotNull(message: 'Bitte gib an, ob du einen Führerschein hast.')]
|
|
private ?bool $hasDriverLicense;
|
|
|
|
private ?bool $confirmTermsOfUse = false;
|
|
|
|
#[Assert\Callback]
|
|
public function validateTermsOfUse(ExecutionContextInterface $executionContext): void
|
|
{
|
|
if (true === $this->hasDriverLicense() && true !== $this->getConfirmTermsOfUse()) {
|
|
$executionContext
|
|
->buildViolation('Bitte bestätige die KfZ-Nutzungsbedingungen.')
|
|
->atPath('confirmTermsOfUse')
|
|
->addViolation()
|
|
;
|
|
}
|
|
}
|
|
|
|
public function __construct(?bool $hasDriverLicense = null)
|
|
{
|
|
$this->hasDriverLicense = $hasDriverLicense;
|
|
}
|
|
|
|
public function hasDriverLicense(): ?bool
|
|
{
|
|
return $this->hasDriverLicense;
|
|
}
|
|
|
|
public function setHasDriverLicense(?bool $hasDriverLicense): static
|
|
{
|
|
$this->hasDriverLicense = $hasDriverLicense;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getConfirmTermsOfUse(): ?bool
|
|
{
|
|
return $this->confirmTermsOfUse;
|
|
}
|
|
|
|
public function setConfirmTermsOfUse(?bool $confirmTermsOfUse): static
|
|
{
|
|
$this->confirmTermsOfUse = $confirmTermsOfUse;
|
|
|
|
return $this;
|
|
}
|
|
|
|
}
|