<?php
namespace App\Entity;
use App\Repository\UserRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
#[ORM\Entity(repositoryClass: UserRepository::class)]
#[UniqueEntity(fields: ['email'], message: 'There is already an account with this email')]
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 180, unique: true)]
private ?string $email = null;
#[ORM\Column]
private array $roles = [];
/**
* @var string The hashed password
*/
#[ORM\Column]
private ?string $password = null;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: Candidature::class)]
private Collection $candidatures;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: CandidatureActivity::class)]
private Collection $candidatureActivities;
#[ORM\OneToMany(mappedBy: 'user', targetEntity: OffreEmploi::class)]
private Collection $offreEmplois;
#[ORM\Column(length: 255)]
private ?string $prenom = null;
#[ORM\Column(length: 255)]
private ?string $nom = null;
#[ORM\Column(length: 255)]
private ?string $uid = null;
#[ORM\Column(length: 255)]
private ?string $visibility = '1';
public function __construct()
{
$this->candidatures = new ArrayCollection();
$this->candidatureActivities = new ArrayCollection();
$this->offreEmplois = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getEmail(): ?string
{
return $this->email;
}
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;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = 'ROLE_USER';
return array_unique($roles);
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
/**
* @see PasswordAuthenticatedUserInterface
*/
public function getPassword(): string
{
return $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
/**
* @return Collection<int, Candidature>
*/
public function getCandidatures(): Collection
{
return $this->candidatures;
}
public function addCandidature(Candidature $candidature): self
{
if (!$this->candidatures->contains($candidature)) {
$this->candidatures->add($candidature);
$candidature->setUser($this);
}
return $this;
}
public function removeCandidature(Candidature $candidature): self
{
if ($this->candidatures->removeElement($candidature)) {
// set the owning side to null (unless already changed)
if ($candidature->getUser() === $this) {
$candidature->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, CandidatureActivity>
*/
public function getCandidatureActivities(): Collection
{
return $this->candidatureActivities;
}
public function addCandidatureActivity(CandidatureActivity $candidatureActivity): self
{
if (!$this->candidatureActivities->contains($candidatureActivity)) {
$this->candidatureActivities->add($candidatureActivity);
$candidatureActivity->setUser($this);
}
return $this;
}
public function removeCandidatureActivity(CandidatureActivity $candidatureActivity): self
{
if ($this->candidatureActivities->removeElement($candidatureActivity)) {
// set the owning side to null (unless already changed)
if ($candidatureActivity->getUser() === $this) {
$candidatureActivity->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, OffreEmploi>
*/
public function getOffreEmplois(): Collection
{
return $this->offreEmplois;
}
public function addOffreEmploi(OffreEmploi $offreEmploi): self
{
if (!$this->offreEmplois->contains($offreEmploi)) {
$this->offreEmplois->add($offreEmploi);
$offreEmploi->setUser($this);
}
return $this;
}
public function removeOffreEmploi(OffreEmploi $offreEmploi): self
{
if ($this->offreEmplois->removeElement($offreEmploi)) {
// set the owning side to null (unless already changed)
if ($offreEmploi->getUser() === $this) {
$offreEmploi->setUser(null);
}
}
return $this;
}
public function getPrenom(): ?string
{
return $this->prenom;
}
public function setPrenom(string $prenom): self
{
$this->prenom = $prenom;
return $this;
}
public function getNom(): ?string
{
return $this->nom;
}
public function setNom(string $nom): self
{
$this->nom = $nom;
return $this;
}
public function getUid(): ?string
{
return $this->uid;
}
public function setUid(string $uid): self
{
$this->uid = $uid;
return $this;
}
public function getVisibility(): ?string
{
return $this->visibility;
}
public function setVisibility(string $visibility): self
{
$this->visibility = $visibility;
return $this;
}
}