src/Entity/User.php line 16

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. #[ORM\Table(name'`user`')]
  12. #[UniqueEntity(fields: ['email'], message'There is already an account with this email')]
  13. class User implements UserInterfacePasswordAuthenticatedUserInterface
  14. {
  15.     #[ORM\Id]
  16.     #[ORM\GeneratedValue]
  17.     #[ORM\Column]
  18.     private ?int $id null;
  19.     #[ORM\Column(length180uniquetrue)]
  20.     private ?string $email null;
  21.     #[ORM\Column]
  22.     private array $roles = [];
  23.     /**
  24.      * @var string The hashed password
  25.      */
  26.     #[ORM\Column]
  27.     private ?string $password null;
  28.     #[ORM\Column(length255)]
  29.     private ?string $nom null;
  30.     #[ORM\Column(length255)]
  31.     private ?string $prenom null;
  32.     #[ORM\Column(length255)]
  33.     private ?string $tel null;
  34.     #[ORM\Column(nullabletrue)]
  35.     private ?bool $status null;
  36.     #[ORM\OneToMany(mappedBy'utilisateur'targetEntityContact::class)]
  37.     private Collection $contacts;
  38.     #[ORM\OneToMany(mappedBy'utilisateur'targetEntityObjet::class)]
  39.     private Collection $objets;
  40.     #[ORM\OneToMany(mappedBy'utilisateur'targetEntityDossier::class)]
  41.     private Collection $dossiers;
  42.     #[ORM\OneToMany(mappedBy'userr'targetEntityVariableValue::class)]
  43.     private Collection $variableValues;
  44.     #[ORM\OneToMany(mappedBy'userr'targetEntityVariable::class)]
  45.     private Collection $variables;
  46.     #[ORM\Column(length30options: ['default' => 'default'])]
  47.     private string $theme 'default';
  48.     public function __construct()
  49.     {
  50.         $this->contacts = new ArrayCollection();
  51.         $this->objets = new ArrayCollection();
  52.         $this->dossiers = new ArrayCollection();
  53.         $this->variableValues = new ArrayCollection();
  54.         $this->variables = new ArrayCollection();
  55.     }
  56.     public function getId(): ?int
  57.     {
  58.         return $this->id;
  59.     }
  60.     public function getEmail(): ?string
  61.     {
  62.         return $this->email;
  63.     }
  64.     public function setEmail(string $email): static
  65.     {
  66.         $this->email $email;
  67.         return $this;
  68.     }
  69.     /**
  70.      * A visual identifier that represents this user.
  71.      *
  72.      * @see UserInterface
  73.      */
  74.     public function getUserIdentifier(): string
  75.     {
  76.         return (string) $this->email;
  77.     }
  78.     /**
  79.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  80.      */
  81.     public function getUsername(): string
  82.     {
  83.         return (string) $this->email;
  84.     }
  85.     /**
  86.      * @see UserInterface
  87.      */
  88.     public function getRoles(): array
  89.     {
  90.         $roles $this->roles;
  91.         // guarantee every user at least has ROLE_USER
  92.         $roles[] = 'ROLE_USER';
  93.         return array_unique($roles);
  94.     }
  95.     public function setRoles(array $roles): static
  96.     {
  97.         $this->roles $roles;
  98.         return $this;
  99.     }
  100.     /**
  101.      * @see PasswordAuthenticatedUserInterface
  102.      */
  103.     public function getPassword(): string
  104.     {
  105.         return $this->password;
  106.     }
  107.     public function setPassword(string $password): static
  108.     {
  109.         $this->password $password;
  110.         return $this;
  111.     }
  112.     /**
  113.      * Returning a salt is only needed, if you are not using a modern
  114.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  115.      *
  116.      * @see UserInterface
  117.      */
  118.     public function getSalt(): ?string
  119.     {
  120.         return null;
  121.     }
  122.     /**
  123.      * @see UserInterface
  124.      */
  125.     public function eraseCredentials(): void
  126.     {
  127.         // If you store any temporary, sensitive data on the user, clear it here
  128.         // $this->plainPassword = null;
  129.     }
  130.     public function getNom(): ?string
  131.     {
  132.         return $this->nom;
  133.     }
  134.     public function setNom(string $nom): static
  135.     {
  136.         $this->nom $nom;
  137.         return $this;
  138.     }
  139.     public function getPrenom(): ?string
  140.     {
  141.         return $this->prenom;
  142.     }
  143.     public function setPrenom(string $prenom): static
  144.     {
  145.         $this->prenom $prenom;
  146.         return $this;
  147.     }
  148.     public function getTel(): ?string
  149.     {
  150.         return $this->tel;
  151.     }
  152.     public function setTel(string $tel): static
  153.     {
  154.         $this->tel $tel;
  155.         return $this;
  156.     }
  157.     public function isStatus(): ?bool
  158.     {
  159.         return $this->status;
  160.     }
  161.     public function setStatus(?bool $status): static
  162.     {
  163.         $this->status $status;
  164.         return $this;
  165.     }
  166.     /**
  167.      * @return Collection<int, Contact>
  168.      */
  169.     public function getContacts(): Collection
  170.     {
  171.         return $this->contacts;
  172.     }
  173.     public function addContact(Contact $contact): static
  174.     {
  175.         if (!$this->contacts->contains($contact)) {
  176.             $this->contacts->add($contact);
  177.             $contact->setUtilisateur($this);
  178.         }
  179.         return $this;
  180.     }
  181.     public function removeContact(Contact $contact): static
  182.     {
  183.         if ($this->contacts->removeElement($contact)) {
  184.             // set the owning side to null (unless already changed)
  185.             if ($contact->getUtilisateur() === $this) {
  186.                 $contact->setUtilisateur(null);
  187.             }
  188.         }
  189.         return $this;
  190.     }
  191.     /**
  192.      * @return Collection<int, Objet>
  193.      */
  194.     public function getObjets(): Collection
  195.     {
  196.         return $this->objets;
  197.     }
  198.     public function addObjet(Objet $objet): static
  199.     {
  200.         if (!$this->objets->contains($objet)) {
  201.             $this->objets->add($objet);
  202.             $objet->setUtilisateur($this);
  203.         }
  204.         return $this;
  205.     }
  206.     public function removeObjet(Objet $objet): static
  207.     {
  208.         if ($this->objets->removeElement($objet)) {
  209.             // set the owning side to null (unless already changed)
  210.             if ($objet->getUtilisateur() === $this) {
  211.                 $objet->setUtilisateur(null);
  212.             }
  213.         }
  214.         return $this;
  215.     }
  216.     /**
  217.      * @return Collection<int, Dossier>
  218.      */
  219.     public function getDossiers(): Collection
  220.     {
  221.         return $this->dossiers;
  222.     }
  223.     public function addDossier(Dossier $dossier): static
  224.     {
  225.         if (!$this->dossiers->contains($dossier)) {
  226.             $this->dossiers->add($dossier);
  227.             $dossier->setUtilisateur($this);
  228.         }
  229.         return $this;
  230.     }
  231.     public function removeDossier(Dossier $dossier): static
  232.     {
  233.         if ($this->dossiers->removeElement($dossier)) {
  234.             // set the owning side to null (unless already changed)
  235.             if ($dossier->getUtilisateur() === $this) {
  236.                 $dossier->setUtilisateur(null);
  237.             }
  238.         }
  239.         return $this;
  240.     }
  241.     /**
  242.      * @return Collection<int, VariableValue>
  243.      */
  244.     public function getVariableValues(): Collection
  245.     {
  246.         return $this->variableValues;
  247.     }
  248.     public function addVariableValue(VariableValue $variableValue): static
  249.     {
  250.         if (!$this->variableValues->contains($variableValue)) {
  251.             $this->variableValues->add($variableValue);
  252.             $variableValue->setUserr($this);
  253.         }
  254.         return $this;
  255.     }
  256.     public function removeVariableValue(VariableValue $variableValue): static
  257.     {
  258.         if ($this->variableValues->removeElement($variableValue)) {
  259.             // set the owning side to null (unless already changed)
  260.             if ($variableValue->getUserr() === $this) {
  261.                 $variableValue->setUserr(null);
  262.             }
  263.         }
  264.         return $this;
  265.     }
  266.     /**
  267.      * @return Collection<int, Variable>
  268.      */
  269.     public function getVariables(): Collection
  270.     {
  271.         return $this->variables;
  272.     }
  273.     public function addVariable(Variable $variable): static
  274.     {
  275.         if (!$this->variables->contains($variable)) {
  276.             $this->variables->add($variable);
  277.             $variable->setUserr($this);
  278.         }
  279.         return $this;
  280.     }
  281.     public function removeVariable(Variable $variable): static
  282.     {
  283.         if ($this->variables->removeElement($variable)) {
  284.             // set the owning side to null (unless already changed)
  285.             if ($variable->getUserr() === $this) {
  286.                 $variable->setUserr(null);
  287.             }
  288.         }
  289.         return $this;
  290.     }
  291.     public function getTheme(): string
  292.     {
  293.         return $this->theme ?: 'default';
  294.     }
  295.     public function setTheme(string $theme): static
  296.     {
  297.         $this->theme $theme;
  298.         return $this;
  299.     }
  300. }