Feat: Implement entities for user and teamer, finalize login process

This commit is contained in:
Björn Fromme
2023-09-12 16:35:06 +02:00
parent 3739decab8
commit 35ca61d21b
27 changed files with 1008 additions and 442 deletions
+284
View File
@@ -0,0 +1,284 @@
<?php
namespace App\Entity;
use App\BusProNet\Model\ProfileResponse;
use App\Entity\Embeddable\Address;
use App\Entity\Embeddable\BankAccount;
use App\Entity\Embeddable\Communication;
use App\Entity\Traits\TimestampableEntity;
use App\Repository\TeamerRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Uid\Uuid;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: TeamerRepository::class)]
class Teamer implements TimestampableEntityInterface
{
use TimestampableEntity;
public const STATUS_NEW = 'new';
public const STATUS_EXISTING = 'existing';
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(type: 'string', length: 36, unique: true)]
private string $uuid;
#[ORM\Column(length: 255)]
private ?string $firstName = null;
#[ORM\Column(length: 255)]
private ?string $lastName = null;
#[ORM\Column(length: 1)]
private ?string $gender = null;
#[ORM\Column(type: Types::DATE_IMMUTABLE)]
private ?\DateTimeImmutable $dateOfBirth = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $academicTitle = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $salutation = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $nationality = null;
#[ORM\Embedded(class: Address::class)]
#[Assert\Valid()]
private ?Address $address = null;
#[ORM\Embedded(class: Communication::class)]
#[Assert\Valid()]
private ?Communication $communication = null;
#[ORM\Embedded(class: BankAccount::class)]
#[Assert\Valid()]
private ?BankAccount $bankAccount = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $taxId = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $healthInsuranceCompany = null;
#[ORM\Column(length: 32)]
private ?string $status = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $remarks = null;
public function __construct()
{
$this->uuid = Uuid::v4();
$this->status = static::STATUS_NEW;
}
public static function fromApiResponse(ProfileResponse $profileResponse): static
{
$instance = new static();
$instance
->setAcademicTitle($profileResponse->getTitle())
->setSalutation($profileResponse->getSalutation())
->setFirstName($profileResponse->getFirstName())
->setLastName($profileResponse->getName())
->setGender($profileResponse->getGender())
->setDateOfBirth($profileResponse->getDateOfBirth())
;
$address = Address::fromApiResponse($profileResponse);
$communication = Communication::fromApiResponse($profileResponse);
$instance
->setAddress($address)
->setCommunication($communication)
;
return $instance;
}
public function getId(): ?int
{
return $this->id;
}
public function getUuid(): string
{
return $this->uuid;
}
public function getFirstName(): ?string
{
return $this->firstName;
}
public function setFirstName(string $firstName): static
{
$this->firstName = $firstName;
return $this;
}
public function getLastName(): ?string
{
return $this->lastName;
}
public function setLastName(string $lastName): static
{
$this->lastName = $lastName;
return $this;
}
public function getGender(): ?string
{
return $this->gender;
}
public function setGender(string $gender): static
{
$this->gender = $gender;
return $this;
}
public function getDateOfBirth(): ?\DateTimeImmutable
{
return $this->dateOfBirth;
}
public function setDateOfBirth(\DateTimeImmutable $dateOfBirth): static
{
$this->dateOfBirth = $dateOfBirth;
return $this;
}
public function getAcademicTitle(): ?string
{
return $this->academicTitle;
}
public function setAcademicTitle(?string $academicTitle): static
{
$this->academicTitle = $academicTitle;
return $this;
}
public function getSalutation(): ?string
{
return $this->salutation;
}
public function setSalutation(?string $salutation): static
{
$this->salutation = $salutation;
return $this;
}
public function getNationality(): ?string
{
return $this->nationality;
}
public function setNationality(string $nationality): static
{
$this->nationality = $nationality;
return $this;
}
public function getAddress(): ?Address
{
return $this->address;
}
public function setAddress(?Address $address): static
{
$this->address = $address;
return $this;
}
public function getCommunication(): ?Communication
{
return $this->communication;
}
public function setCommunication(?Communication $communication): static
{
$this->communication = $communication;
return $this;
}
public function getBankAccount(): ?BankAccount
{
return $this->bankAccount;
}
public function setBankAccount(?BankAccount $bankAccount): static
{
$this->bankAccount = $bankAccount;
return $this;
}
public function getTaxId(): ?string
{
return $this->taxId;
}
public function setTaxId(?string $taxId): static
{
$this->taxId = $taxId;
return $this;
}
public function getHealthInsuranceCompany(): ?string
{
return $this->healthInsuranceCompany;
}
public function setHealthInsuranceCompany(?string $healthInsuranceCompany): static
{
$this->healthInsuranceCompany = $healthInsuranceCompany;
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(string $status): static
{
$this->status = $status;
return $this;
}
public function getRemarks(): ?string
{
return $this->remarks;
}
public function setRemarks(?string $remarks): static
{
$this->remarks = $remarks;
return $this;
}
}