src/Entity/User.php line 14

  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\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  8. use Symfony\Component\Security\Core\User\UserInterface;
  9. #[ORM\Entity(repositoryClassUserRepository::class)]
  10. #[ORM\Table(name'ujr_users')]
  11. class User implements UserInterfacePasswordAuthenticatedUserInterface
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column]
  16.     private ?int $id null;
  17.     #[ORM\Column(length180uniquetrue)]
  18.     private ?string $email null;
  19.     #[ORM\Column]
  20.     private array $roles = [];
  21.     /**
  22.      * @var string The hashed password
  23.      */
  24.     #[ORM\Column]
  25.     private ?string $password null;
  26.     #[ORM\OneToMany(mappedBy'user'targetEntityDirecteur::class)]
  27.     private Collection $directeurs;
  28.     #[ORM\OneToMany(mappedBy'user'targetEntityResponsableStructure::class)]
  29.     private Collection $responsableStructures;
  30.     #[ORM\OneToMany(mappedBy'user'targetEntityChercheur::class)]
  31.     private Collection $chercheurs;
  32.     #[ORM\OneToMany(mappedBy'user'targetEntityProjet::class)]
  33.     private Collection $projets;
  34.     #[ORM\OneToMany(mappedBy'user'targetEntityTag::class)]
  35.     private Collection $tags;
  36.     #[ORM\OneToMany(mappedBy'user'targetEntityPublication::class)]
  37.     private Collection $publications;
  38.     #[ORM\Column(length255nullabletrue)]
  39.     private ?string $username null;
  40.     #[ORM\Column(nullabletrue)]
  41.     private ?int $etat null;
  42.     public function __construct()
  43.     {
  44.         $this->directeurs = new ArrayCollection();
  45.         $this->responsableStructures = new ArrayCollection();
  46.         $this->chercheurs = new ArrayCollection();
  47.         $this->projets = new ArrayCollection();
  48.         $this->tags = new ArrayCollection();
  49.         $this->publications = new ArrayCollection();
  50.     }
  51.     public function getId(): ?int
  52.     {
  53.         return $this->id;
  54.     }
  55.     public function getEmail(): ?string
  56.     {
  57.         return $this->email;
  58.     }
  59.     public function setEmail(string $email): self
  60.     {
  61.         $this->email $email;
  62.         return $this;
  63.     }
  64.     /**
  65.      * A visual identifier that represents this user.
  66.      *
  67.      * @see UserInterface
  68.      */
  69.     public function getUserIdentifier(): string
  70.     {
  71.         return (string) $this->email;
  72.     }
  73.     /**
  74.      * @see UserInterface
  75.      */
  76.     public function getRoles(): array
  77.     {
  78.         $roles $this->roles;
  79.         // guarantee every user at least has ROLE_USER
  80.         $roles[] = 'ROLE_USER';
  81.         return array_unique($roles);
  82.     }
  83.     public function setRoles(array $roles): self
  84.     {
  85.         $this->roles $roles;
  86.         return $this;
  87.     }
  88.     /**
  89.      * @see PasswordAuthenticatedUserInterface
  90.      */
  91.     public function getPassword(): string
  92.     {
  93.         return $this->password;
  94.     }
  95.     public function setPassword(string $password): self
  96.     {
  97.         $this->password $password;
  98.         return $this;
  99.     }
  100.     /**
  101.      * @see UserInterface
  102.      */
  103.     public function eraseCredentials()
  104.     {
  105.         // If you store any temporary, sensitive data on the user, clear it here
  106.         // $this->plainPassword = null;
  107.     }
  108.     /**
  109.      * @return Collection<int, Directeur>
  110.      */
  111.     public function getDirecteurs(): Collection
  112.     {
  113.         return $this->directeurs;
  114.     }
  115.     public function addDirecteur(Directeur $directeur): self
  116.     {
  117.         if (!$this->directeurs->contains($directeur)) {
  118.             $this->directeurs->add($directeur);
  119.             $directeur->setUser($this);
  120.         }
  121.         return $this;
  122.     }
  123.     public function removeDirecteur(Directeur $directeur): self
  124.     {
  125.         if ($this->directeurs->removeElement($directeur)) {
  126.             // set the owning side to null (unless already changed)
  127.             if ($directeur->getUser() === $this) {
  128.                 $directeur->setUser(null);
  129.             }
  130.         }
  131.         return $this;
  132.     }
  133.     /**
  134.      * @return Collection<int, ResponsableStructure>
  135.      */
  136.     public function getResponsableStructures(): Collection
  137.     {
  138.         return $this->responsableStructures;
  139.     }
  140.     public function addResponsableStructure(ResponsableStructure $responsableStructure): self
  141.     {
  142.         if (!$this->responsableStructures->contains($responsableStructure)) {
  143.             $this->responsableStructures->add($responsableStructure);
  144.             $responsableStructure->setUser($this);
  145.         }
  146.         return $this;
  147.     }
  148.     public function removeResponsableStructure(ResponsableStructure $responsableStructure): self
  149.     {
  150.         if ($this->responsableStructures->removeElement($responsableStructure)) {
  151.             // set the owning side to null (unless already changed)
  152.             if ($responsableStructure->getUser() === $this) {
  153.                 $responsableStructure->setUser(null);
  154.             }
  155.         }
  156.         return $this;
  157.     }
  158.     /**
  159.      * @return Collection<int, Chercheur>
  160.      */
  161.     public function getChercheurs(): Collection
  162.     {
  163.         return $this->chercheurs;
  164.     }
  165.     public function addChercheur(Chercheur $chercheur): self
  166.     {
  167.         if (!$this->chercheurs->contains($chercheur)) {
  168.             $this->chercheurs->add($chercheur);
  169.             $chercheur->setUser($this);
  170.         }
  171.         return $this;
  172.     }
  173.     public function removeChercheur(Chercheur $chercheur): self
  174.     {
  175.         if ($this->chercheurs->removeElement($chercheur)) {
  176.             // set the owning side to null (unless already changed)
  177.             if ($chercheur->getUser() === $this) {
  178.                 $chercheur->setUser(null);
  179.             }
  180.         }
  181.         return $this;
  182.     }
  183.     /**
  184.      * @return Collection<int, Projet>
  185.      */
  186.     public function getProjets(): Collection
  187.     {
  188.         return $this->projets;
  189.     }
  190.     public function addProjet(Projet $projet): self
  191.     {
  192.         if (!$this->projets->contains($projet)) {
  193.             $this->projets->add($projet);
  194.             $projet->setUser($this);
  195.         }
  196.         return $this;
  197.     }
  198.     public function removeProjet(Projet $projet): self
  199.     {
  200.         if ($this->projets->removeElement($projet)) {
  201.             // set the owning side to null (unless already changed)
  202.             if ($projet->getUser() === $this) {
  203.                 $projet->setUser(null);
  204.             }
  205.         }
  206.         return $this;
  207.     }
  208.     public function __toString(): string
  209.     {
  210.         return $this->email;
  211.     }
  212.     /**
  213.      * @return Collection<int, Tag>
  214.      */
  215.     public function getTags(): Collection
  216.     {
  217.         return $this->tags;
  218.     }
  219.     public function addTag(Tag $tag): self
  220.     {
  221.         if (!$this->tags->contains($tag)) {
  222.             $this->tags->add($tag);
  223.             $tag->setUser($this);
  224.         }
  225.         return $this;
  226.     }
  227.     public function removeTag(Tag $tag): self
  228.     {
  229.         if ($this->tags->removeElement($tag)) {
  230.             // set the owning side to null (unless already changed)
  231.             if ($tag->getUser() === $this) {
  232.                 $tag->setUser(null);
  233.             }
  234.         }
  235.         return $this;
  236.     }
  237.     /**
  238.      * @return Collection<int, Publication>
  239.      */
  240.     public function getPublications(): Collection
  241.     {
  242.         return $this->publications;
  243.     }
  244.     public function addPublication(Publication $publication): self
  245.     {
  246.         if (!$this->publications->contains($publication)) {
  247.             $this->publications->add($publication);
  248.             $publication->setUser($this);
  249.         }
  250.         return $this;
  251.     }
  252.     public function removePublication(Publication $publication): self
  253.     {
  254.         if ($this->publications->removeElement($publication)) {
  255.             // set the owning side to null (unless already changed)
  256.             if ($publication->getUser() === $this) {
  257.                 $publication->setUser(null);
  258.             }
  259.         }
  260.         return $this;
  261.     }
  262.     public function getUsername(): ?string
  263.     {
  264.         return $this->username;
  265.     }
  266.     public function setUsername(?string $username): self
  267.     {
  268.         $this->username $username;
  269.         return $this;
  270.     }
  271.     public function getEtat(): ?int
  272.     {
  273.         return $this->etat;
  274.     }
  275.     public function setEtat(?int $etat): self
  276.     {
  277.         $this->etat $etat;
  278.         return $this;
  279.     }
  280. }