src/Entity/User.php line 17

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