src/Entity/User.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  9. use Symfony\Component\Security\Core\User\UserInterface;
  10. #[ORM\Entity(repositoryClassUserRepository::class)]
  11. #[UniqueEntity(fields: ['email'], message'There is already an account with this email')]
  12. class User implements UserInterfacePasswordAuthenticatedUserInterface
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column]
  17.     private ?int $id null;
  18.     #[ORM\Column(length180uniquetrue)]
  19.     private ?string $email null;
  20.     #[ORM\Column]
  21.     private array $roles = [];
  22.     /**
  23.      * @var string The hashed password
  24.      */
  25.     #[ORM\Column]
  26.     private ?string $password null;
  27.     #[ORM\OneToMany(mappedBy'user'targetEntityCandidature::class)]
  28.     private Collection $candidatures;
  29.     #[ORM\OneToMany(mappedBy'user'targetEntityCandidatureActivity::class)]
  30.     private Collection $candidatureActivities;
  31.     #[ORM\OneToMany(mappedBy'user'targetEntityOffreEmploi::class)]
  32.     private Collection $offreEmplois;
  33.     #[ORM\Column(length255)]
  34.     private ?string $prenom null;
  35.     #[ORM\Column(length255)]
  36.     private ?string $nom null;
  37.     #[ORM\Column(length255)]
  38.     private ?string $uid null;
  39.     #[ORM\Column(length255)]
  40.     private ?string $visibility '1';
  41.     public function __construct()
  42.     {
  43.         $this->candidatures = new ArrayCollection();
  44.         $this->candidatureActivities = new ArrayCollection();
  45.         $this->offreEmplois = new ArrayCollection();
  46.     }
  47.     public function getId(): ?int
  48.     {
  49.         return $this->id;
  50.     }
  51.     public function getEmail(): ?string
  52.     {
  53.         return $this->email;
  54.     }
  55.     public function setEmail(string $email): self
  56.     {
  57.         $this->email $email;
  58.         return $this;
  59.     }
  60.     /**
  61.      * A visual identifier that represents this user.
  62.      *
  63.      * @see UserInterface
  64.      */
  65.     public function getUserIdentifier(): string
  66.     {
  67.         return (string) $this->email;
  68.     }
  69.     /**
  70.      * @see UserInterface
  71.      */
  72.     public function getRoles(): array
  73.     {
  74.         $roles $this->roles;
  75.         // guarantee every user at least has ROLE_USER
  76.         $roles[] = 'ROLE_USER';
  77.         return array_unique($roles);
  78.     }
  79.     public function setRoles(array $roles): self
  80.     {
  81.         $this->roles $roles;
  82.         return $this;
  83.     }
  84.     /**
  85.      * @see PasswordAuthenticatedUserInterface
  86.      */
  87.     public function getPassword(): string
  88.     {
  89.         return $this->password;
  90.     }
  91.     public function setPassword(string $password): self
  92.     {
  93.         $this->password $password;
  94.         return $this;
  95.     }
  96.     /**
  97.      * @see UserInterface
  98.      */
  99.     public function eraseCredentials()
  100.     {
  101.         // If you store any temporary, sensitive data on the user, clear it here
  102.         // $this->plainPassword = null;
  103.     }
  104.     /**
  105.      * @return Collection<int, Candidature>
  106.      */
  107.     public function getCandidatures(): Collection
  108.     {
  109.         return $this->candidatures;
  110.     }
  111.     public function addCandidature(Candidature $candidature): self
  112.     {
  113.         if (!$this->candidatures->contains($candidature)) {
  114.             $this->candidatures->add($candidature);
  115.             $candidature->setUser($this);
  116.         }
  117.         return $this;
  118.     }
  119.     public function removeCandidature(Candidature $candidature): self
  120.     {
  121.         if ($this->candidatures->removeElement($candidature)) {
  122.             // set the owning side to null (unless already changed)
  123.             if ($candidature->getUser() === $this) {
  124.                 $candidature->setUser(null);
  125.             }
  126.         }
  127.         return $this;
  128.     }
  129.     /**
  130.      * @return Collection<int, CandidatureActivity>
  131.      */
  132.     public function getCandidatureActivities(): Collection
  133.     {
  134.         return $this->candidatureActivities;
  135.     }
  136.     public function addCandidatureActivity(CandidatureActivity $candidatureActivity): self
  137.     {
  138.         if (!$this->candidatureActivities->contains($candidatureActivity)) {
  139.             $this->candidatureActivities->add($candidatureActivity);
  140.             $candidatureActivity->setUser($this);
  141.         }
  142.         return $this;
  143.     }
  144.     public function removeCandidatureActivity(CandidatureActivity $candidatureActivity): self
  145.     {
  146.         if ($this->candidatureActivities->removeElement($candidatureActivity)) {
  147.             // set the owning side to null (unless already changed)
  148.             if ($candidatureActivity->getUser() === $this) {
  149.                 $candidatureActivity->setUser(null);
  150.             }
  151.         }
  152.         return $this;
  153.     }
  154.     /**
  155.      * @return Collection<int, OffreEmploi>
  156.      */
  157.     public function getOffreEmplois(): Collection
  158.     {
  159.         return $this->offreEmplois;
  160.     }
  161.     public function addOffreEmploi(OffreEmploi $offreEmploi): self
  162.     {
  163.         if (!$this->offreEmplois->contains($offreEmploi)) {
  164.             $this->offreEmplois->add($offreEmploi);
  165.             $offreEmploi->setUser($this);
  166.         }
  167.         return $this;
  168.     }
  169.     public function removeOffreEmploi(OffreEmploi $offreEmploi): self
  170.     {
  171.         if ($this->offreEmplois->removeElement($offreEmploi)) {
  172.             // set the owning side to null (unless already changed)
  173.             if ($offreEmploi->getUser() === $this) {
  174.                 $offreEmploi->setUser(null);
  175.             }
  176.         }
  177.         return $this;
  178.     }
  179.     public function getPrenom(): ?string
  180.     {
  181.         return $this->prenom;
  182.     }
  183.     public function setPrenom(string $prenom): self
  184.     {
  185.         $this->prenom $prenom;
  186.         return $this;
  187.     }
  188.     public function getNom(): ?string
  189.     {
  190.         return $this->nom;
  191.     }
  192.     public function setNom(string $nom): self
  193.     {
  194.         $this->nom $nom;
  195.         return $this;
  196.     }
  197.     public function getUid(): ?string
  198.     {
  199.         return $this->uid;
  200.     }
  201.     public function setUid(string $uid): self
  202.     {
  203.         $this->uid $uid;
  204.         return $this;
  205.     }
  206.     public function getVisibility(): ?string
  207.     {
  208.         return $this->visibility;
  209.     }
  210.     public function setVisibility(string $visibility): self
  211.     {
  212.         $this->visibility $visibility;
  213.         return $this;
  214.     }
  215. }