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
+63 -53
View File
@@ -2,48 +2,82 @@
namespace App\Entity;
use App\Entity\Embeddable\Address;
use App\Entity\Embeddable\Communication;
use App\Entity\Embeddable\Profile;
use App\Entity\Traits\TimestampableEntity;
use App\Repository\UserRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Uid\Uuid;
#[ORM\Entity(repositoryClass: UserRepository::class)]
class User implements UserInterface
class User implements UserInterface, TimestampableEntityInterface
{
use TimestampableEntity;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(type: 'string', length: 36, unique: true)]
private string $uuid;
#[ORM\Column]
private ?int $busProAddressId = null;
#[ORM\Column]
private ?int $busProPersonId = null;
#[ORM\Column(length: 255)]
private ?string $email = null;
#[ORM\Embedded(class: Profile::class)]
#[Assert\Valid()]
private ?Profile $profile = null;
#[ORM\Embedded(class: Address::class)]
#[Assert\Valid()]
private ?Address $address = null;
#[ORM\Embedded(class: Communication::class)]
#[Assert\Valid()]
private ?Communication $communication = null;
#[ORM\Column(type: 'json')]
private array $roles = [];
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $lastLoginAt = null;
#[ORM\OneToOne(cascade: ['persist', 'remove'])]
private ?Teamer $teamer = null;
public function __construct()
{
$this->uuid = Uuid::v4();
}
public function getId(): ?int
{
return $this->id;
}
public function getUuid(): string
{
return $this->uuid;
}
public function getBusProAddressId(): ?int
{
return $this->busProAddressId;
}
public function setBusProAddressId(int $busProAddressId): static
{
$this->busProAddressId = $busProAddressId;
return $this;
}
public function getBusProPersonId(): ?int
{
return $this->busProPersonId;
}
public function setBusProPersonId(int $busProPersonId): static
{
$this->busProPersonId = $busProPersonId;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
@@ -56,42 +90,6 @@ class User implements UserInterface
return $this;
}
public function getProfile(): ?Profile
{
return $this->profile;
}
public function setProfile(?Profile $profile): static
{
$this->profile = $profile;
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 getRoles(): array
{
$roles = ['ROLE_USER', ...$this->roles];
@@ -142,4 +140,16 @@ class User implements UserInterface
{
return $this->email;
}
public function getTeamer(): ?Teamer
{
return $this->teamer;
}
public function setTeamer(?Teamer $teamer): static
{
$this->teamer = $teamer;
return $this;
}
}