316 lines
7.2 KiB
PHP
316 lines
7.2 KiB
PHP
<?php
|
|
|
|
namespace App\Entity;
|
|
|
|
use App\Repository\ParticipantRepository;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Doctrine\Common\Collections\Collection;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
|
|
use Symfony\Component\Security\Core\User\UserInterface;
|
|
|
|
#[ORM\Entity(repositoryClass: ParticipantRepository::class)]
|
|
#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_EMAIL', fields: ['email'])]
|
|
#[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_PSEUDO', fields: ['pseudo'])]
|
|
class Participant implements UserInterface, PasswordAuthenticatedUserInterface
|
|
{
|
|
#[ORM\Id]
|
|
#[ORM\Column(type: 'guid', unique: true)]
|
|
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
|
|
#[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
|
|
private ?string $idParticipant = null;
|
|
|
|
#[ORM\Column(length: 255)]
|
|
private ?string $nom = null;
|
|
|
|
#[ORM\Column(length: 255)]
|
|
private ?string $prenom = null;
|
|
|
|
#[ORM\Column(length: 255, nullable: false)]
|
|
private ?string $pseudo = null;
|
|
|
|
#[ORM\Column(length: 255, nullable: true)]
|
|
private ?string $telephone = null;
|
|
|
|
#[ORM\Column(length: 255, nullable: false)]
|
|
private ?string $email = null;
|
|
|
|
#[ORM\Column]
|
|
private ?bool $administrateur = null;
|
|
|
|
#[ORM\Column]
|
|
private ?bool $actif = null;
|
|
|
|
#[ORM\Column]
|
|
private ?bool $pending = null;
|
|
|
|
#[ORM\Column]
|
|
private array $roles = [];
|
|
|
|
#[ORM\Column]
|
|
private ?string $password = null;
|
|
|
|
#[ORM\Column(length: 255, nullable: true)]
|
|
private ?string $fileName = null;
|
|
|
|
#[ORM\ManyToOne(targetEntity: Site::class, inversedBy: 'participants')]
|
|
#[ORM\JoinColumn(name: 'site_id', referencedColumnName: 'id_site', nullable: true)]
|
|
private ?Site $site = null;
|
|
|
|
/**
|
|
* @var Collection<int, Sortie>
|
|
*/
|
|
#[ORM\OneToMany(targetEntity: Sortie::class, mappedBy: 'organisateur')]
|
|
private Collection $sortiesOrganisateur;
|
|
|
|
/**
|
|
* @var Collection<int, Sortie>
|
|
*/
|
|
#[ORM\ManyToMany(targetEntity: Sortie::class, inversedBy: 'participants')]
|
|
#[ORM\JoinTable(name: 'participant_sortie')]
|
|
#[ORM\JoinColumn(name: 'participant_id', referencedColumnName: 'id_participant')]
|
|
#[ORM\InverseJoinColumn(name: 'sortie_id', referencedColumnName: 'id_sortie')]
|
|
private Collection $sortiesParticipants;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->sortiesOrganisateur = new ArrayCollection();
|
|
$this->sortiesParticipants = new ArrayCollection();
|
|
}
|
|
|
|
public function getIdParticipant(): ?string
|
|
{
|
|
return $this->idParticipant;
|
|
}
|
|
|
|
public function getNom(): ?string
|
|
{
|
|
return $this->nom;
|
|
}
|
|
|
|
public function setNom(string $nom): self
|
|
{
|
|
$this->nom = $nom;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getPending(): ?bool
|
|
{
|
|
return $this->pending;
|
|
}
|
|
|
|
public function setPending(?bool $pending): void
|
|
{
|
|
$this->pending = $pending;
|
|
}
|
|
|
|
public function getPseudo(): ?string
|
|
{
|
|
return $this->pseudo;
|
|
}
|
|
|
|
public function setPseudo(string $pseudo): self
|
|
{
|
|
$this->pseudo = $pseudo;
|
|
return $this;
|
|
}
|
|
|
|
public function getPrenom(): ?string
|
|
{
|
|
return $this->prenom;
|
|
}
|
|
|
|
public function setPrenom(string $prenom): self
|
|
{
|
|
$this->prenom = $prenom;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getTelephone(): ?string
|
|
{
|
|
return $this->telephone;
|
|
}
|
|
|
|
public function setTelephone(?string $telephone): self
|
|
{
|
|
$this->telephone = $telephone;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getEmail(): ?string
|
|
{
|
|
return $this->email;
|
|
}
|
|
|
|
public function setEmail(string $email): static
|
|
{
|
|
$this->email = $email;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* A visual identifier that represents this user.
|
|
*
|
|
* @see UserInterface
|
|
*/
|
|
public function getUserIdentifier(): string
|
|
{
|
|
return (string) $this->pseudo;
|
|
}
|
|
|
|
/**
|
|
* @see UserInterface
|
|
*
|
|
* @return list<string>
|
|
*/
|
|
public function getRoles(): array
|
|
{
|
|
$roles = $this->roles;
|
|
// guarantee every user at least has ROLE_USER
|
|
$roles[] = 'ROLE_USER';
|
|
|
|
return array_unique($roles);
|
|
}
|
|
|
|
/**
|
|
* @param list<string> $roles
|
|
*/
|
|
public function setRoles(array $roles): static
|
|
{
|
|
$this->roles = $roles;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function isAdministrateur(): ?bool
|
|
{
|
|
return $this->administrateur;
|
|
}
|
|
|
|
public function setAdministrateur(bool $administrateur): self
|
|
{
|
|
$this->administrateur = $administrateur;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function isActif(): ?bool
|
|
{
|
|
return $this->actif;
|
|
}
|
|
|
|
public function setActif(bool $actif): self
|
|
{
|
|
$this->actif = $actif;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @see PasswordAuthenticatedUserInterface
|
|
*/
|
|
public function getPassword(): ?string
|
|
{
|
|
return $this->password;
|
|
}
|
|
|
|
public function setPassword(string $password): static
|
|
{
|
|
$this->password = $password;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @see UserInterface
|
|
*/
|
|
public function eraseCredentials(): void
|
|
{
|
|
// If you store any temporary, sensitive data on the user, clear it here
|
|
// $this->plainPassword = null;
|
|
}
|
|
|
|
public function getSite(): ?Site
|
|
{
|
|
return $this->site;
|
|
}
|
|
|
|
public function setSite(?Site $site): self
|
|
{
|
|
$this->site = $site;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return Collection<int, Sortie>
|
|
*/
|
|
public function getSortiesOrganisateur(): Collection
|
|
{
|
|
return $this->sortiesOrganisateur;
|
|
}
|
|
|
|
public function addSortieOrganisateur(Sortie $sortie): self
|
|
{
|
|
if (!$this->sortiesOrganisateur->contains($sortie)) {
|
|
$this->sortiesOrganisateur->add($sortie);
|
|
$sortie->setOrganisateur($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeSortieOrganisateur(Sortie $sortie): self
|
|
{
|
|
if ($this->sortiesOrganisateur->removeElement($sortie)) {
|
|
// Set the owning side to null (unless already changed)
|
|
if ($sortie->getOrganisateur() === $this) {
|
|
$sortie->setOrganisateur(null);
|
|
}
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getFileName(): ?string
|
|
{
|
|
return $this->fileName;
|
|
}
|
|
|
|
public function setFileName(?string $fileName): void
|
|
{
|
|
$this->fileName = $fileName;
|
|
}
|
|
|
|
/**
|
|
* @return Collection<int, Sortie>
|
|
*/
|
|
public function getSortiesParticipants(): Collection
|
|
{
|
|
return $this->sortiesParticipants;
|
|
}
|
|
|
|
public function addSortiesParticipant(Sortie $sortiesParticipant): static
|
|
{
|
|
if (!$this->sortiesParticipants->contains($sortiesParticipant)) {
|
|
$this->sortiesParticipants->add($sortiesParticipant);
|
|
$sortiesParticipant->addParticipant($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeSortiesParticipant(Sortie $sortiesParticipant): static
|
|
{
|
|
if ($this->sortiesParticipants->removeElement($sortiesParticipant)) {
|
|
$sortiesParticipant->removeParticipant($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
}
|