<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use App\Repository\UserRepository;
use Symfony\Component\Uid\Uuid;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
/**
* @ORM\Entity(repositoryClass=UserRepository::class)
* @UniqueEntity(fields={"email"}, message="Cet email est déjà associé à un compte")
*/
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private int $id;
/**
* @ORM\Column(type="string", nullable=true)
*/
private ?string $uuid;
/**
* @ORM\Column(type="string", length=180, unique=true)
*/
private string $email;
/**
* @ORM\Column(type="json")
*/
private array $roles = [];
public string $role;
/**
* @var string The hashed password
* @ORM\Column(type="string", nullable=true)
*/
private ?string $password;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $nom;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $prenom;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private ?bool $statut = false;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $activation;
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
*/
private ?\DateTimeImmutable $createdAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private ?\DateTime $updatedAt;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $token;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private ?bool $online = false;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private ?\DateTime $loginAt;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $provider;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $sexe;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $src;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $alt;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $title;
/**
* @ORM\OneToMany(targetEntity=Arbre::class, mappedBy="user", cascade={"persist", "remove"})
*/
private $arbres;
public function __construct()
{
$this->uuid = Uuid::v4();
$this->arbres = new ArrayCollection();
}
/**
* getId
*
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* getUuid
*
* @return void
*/
public function getUuid()
{
return $this->uuid;
}
/**
* setUuid
*
* @param mixed $uuid
* @return self
*/
public function setUuid($uuid): self
{
$this->uuid = $uuid;
return $this;
}
/**
* getEmail
*
* @return string
*/
public function getEmail(): ?string
{
return $this->email;
}
/**
* setEmail
*
* @param mixed $email
* @return self
*/
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUserIdentifier(): string
{
return (string) $this->email;
}
/**
* @deprecated since Symfony 5.3, use getUserIdentifier instead
*/
public function getUsername(): string
{
return (string) $this->email;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
// $roles[] = 'ROLE_USER';
return array_unique($roles);
}
/**
* setRoles
*
* @param mixed $roles
* @return self
*/
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
/**
* @see PasswordAuthenticatedUserInterface
*/
public function getPassword(): ?string
{
return $this->password;
}
/**
* setPassword
*
* @param mixed $password
* @return self
*/
public function setPassword(?string $password): self
{
$this->password = $password;
return $this;
}
/**
* Returning a salt is only needed, if you are not using a modern
* hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
*
* @see UserInterface
*/
public function getSalt(): ?string
{
return null;
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
/**
* getNom
*
* @return string
*/
public function getNom(): ?string
{
return $this->nom;
}
/**
* setNom
*
* @param mixed $nom
* @return self
*/
public function setNom(?string $nom): self
{
$this->nom = $nom;
return $this;
}
/**
* getPrenom
*
* @return string
*/
public function getPrenom(): ?string
{
return $this->prenom;
}
/**
* setPrenom
*
* @param mixed $prenom
* @return self
*/
public function setPrenom(?string $prenom): self
{
$this->prenom = $prenom;
return $this;
}
/**
* isStatut
*
* @return bool
*/
public function isStatut(): ?bool
{
return $this->statut;
}
/**
* setStatut
*
* @param mixed $statut
* @return self
*/
public function setStatut(?bool $statut): self
{
$this->statut = $statut;
return $this;
}
/**
* getActivation
*
* @return string
*/
public function getActivation(): ?string
{
return $this->activation;
}
/**
* setActivation
*
* @param mixed $activation
* @return self
*/
public function setActivation(?string $activation): self
{
$this->activation = $activation;
return $this;
}
/**
* getCreatedAt
*
* @return DateTimeImmutable
*/
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
/**
* setCreatedAt
*
* @param mixed $createdAt
* @return self
*/
public function setCreatedAt(?\DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
/**
* getUpdatedAt
*
* @return DateTimeInterface
*/
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
/**
* setUpdatedAt
*
* @param mixed $updatedAt
* @return self
*/
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* getToken
*
* @return string
*/
public function getToken(): ?string
{
return $this->token;
}
/**
* setToken
*
* @param mixed $token
* @return self
*/
public function setToken(?string $token): self
{
$this->token = $token;
return $this;
}
/**
* isOnline
*
* @return bool
*/
public function isOnline(): ?bool
{
return $this->online;
}
/**
* setOnline
*
* @param mixed $online
* @return self
*/
public function setOnline(?bool $online): self
{
$this->online = $online;
return $this;
}
/**
* getLoginAt
*
* @return DateTimeInterface
*/
public function getLoginAt(): ?\DateTimeInterface
{
return $this->loginAt;
}
/**
* setLoginAt
*
* @param mixed $loginAt
* @return self
*/
public function setLoginAt(?\DateTimeInterface $loginAt): self
{
$this->loginAt = $loginAt;
return $this;
}
/**
* getProvider
*
* @return string
*/
public function getProvider(): ?string
{
return $this->provider;
}
/**
* setProvider
*
* @param mixed $provider
* @return self
*/
public function setProvider(?string $provider): self
{
$this->provider = $provider;
return $this;
}
/**
* getSexe
*
* @return string
*/
public function getSexe(): ?string
{
return $this->sexe;
}
/**
* setSexe
*
* @param mixed $sexe
* @return self
*/
public function setSexe(?string $sexe): self
{
$this->sexe = $sexe;
return $this;
}
/**
* getSrc
*
* @return string
*/
public function getSrc(): ?string
{
return $this->src;
}
/**
* setSrc
*
* @param mixed $src
* @return self
*/
public function setSrc(?string $src): self
{
$this->src = $src;
return $this;
}
/**
* getAlt
*
* @return string
*/
public function getAlt(): ?string
{
return $this->alt;
}
/**
* setAlt
*
* @param mixed $alt
* @return self
*/
public function setAlt(?string $alt): self
{
$this->alt = $alt;
return $this;
}
/**
* getTitle
*
* @return string
*/
public function getTitle(): ?string
{
return $this->title;
}
/**
* setTitle
*
* @param mixed $title
* @return self
*/
public function setTitle(?string $title): self
{
$this->title = $title;
return $this;
}
/**
* @return Collection<int, Arbre>
*/
public function getArbres(): Collection
{
return $this->arbres;
}
public function addArbre(Arbre $arbre): self
{
if (!$this->arbres->contains($arbre)) {
$this->arbres[] = $arbre;
$arbre->setUser($this);
}
return $this;
}
public function removeArbre(Arbre $arbre): self
{
if ($this->arbres->removeElement($arbre)) {
// set the owning side to null (unless already changed)
if ($arbre->getUser() === $this) {
$arbre->setUser(null);
}
}
return $this;
}
}