src/Entity/User.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Security\Core\User\UserInterface;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. /**
  10.  * @ORM\Entity(repositoryClass="App\Repository\UserRepository")
  11.  * @UniqueEntity(
  12.  *     fields = {"email"},
  13.  *     message = "L'email indiqué est déjà utilisé !"
  14.  * )
  15.  */
  16. class User implements UserInterface
  17. {
  18.     /**
  19.      * @ORM\Id()
  20.      * @ORM\GeneratedValue()
  21.      * @ORM\Column(type="integer")
  22.      */
  23.     private $id;
  24.     /**
  25.      * @ORM\Column(type="json")
  26.      */
  27.     private $roles = [];
  28.     /**
  29.      * @ORM\Column(type="string", length=25, nullable=true)
  30.      */
  31.     private $type;
  32.     /**
  33.      * @ORM\Column(type="string", length=255, nullable=true)
  34.      */
  35.     private $username;
  36.     /**
  37.      * @ORM\Column(type="string", length=255)
  38.      * @Assert\Email(
  39.      *     message = "L'email '{{ value }}' n'est pas un email valide !"
  40.      * )
  41.      */
  42.     private $email;
  43.     /**
  44.      * @ORM\Column(type="string", length=64)
  45.      * @Assert\Length(
  46.      *      min = 8,
  47.      *      minMessage = "Le mot de passe doit comporter au moins {{ limit }} caractères !",
  48.      * )
  49.      */
  50.     private $password;
  51.     /**
  52.      * @Assert\EqualTo(propertyPath="password", message="La confirmation du mot de passe ne correspond pas au mot de passe indiqué !")
  53.      */
  54.     private $confirm_password;
  55.     /**
  56.      * @ORM\Column(type="boolean")
  57.      */
  58.     private $accepteBdd;
  59.     /**
  60.      * @ORM\Column(type="boolean", nullable=true)
  61.      */
  62.     private $accepteTransmission;
  63.     /**
  64.      * @ORM\Column(type="boolean")
  65.      */
  66.     private $accepteDroitRetrait;
  67.     /**
  68.      * @ORM\OneToMany(targetEntity="App\Entity\Structure", mappedBy="user", cascade={"persist"}, orphanRemoval=true)
  69.      */
  70.     private $structures;
  71.     /**
  72.      * @ORM\OneToMany(targetEntity="App\Entity\ProductionCineAudio", mappedBy="user", cascade={"persist"}, orphanRemoval=true)
  73.      */
  74.     private $productionsCineAudio;
  75.     /**
  76.      * @ORM\OneToMany(targetEntity="App\Entity\ProductionCom", mappedBy="user", cascade={"persist"}, orphanRemoval=true)
  77.      */
  78.     private $productionsCom;
  79.     /**
  80.      * @ORM\OneToMany(targetEntity="App\Entity\PrestataireTechnique", mappedBy="user", cascade={"persist"}, orphanRemoval=true)
  81.      */
  82.     private $prestatairesTechniques;
  83.     /**
  84.      * @ORM\OneToMany(targetEntity="App\Entity\PrestataireLogistique", mappedBy="user", cascade={"persist"}, orphanRemoval=true)
  85.      */
  86.     private $prestatairesLogistiques;
  87.     /**
  88.      * @ORM\OneToMany(targetEntity="App\Entity\Action", mappedBy="user", cascade={"persist"}, orphanRemoval=true)
  89.      * @Assert\Valid()
  90.      * @ORM\OrderBy({"date" = "ASC"})
  91.      */
  92.     private $actions;
  93.     /**
  94.      * @ORM\Column(type="string", length=25)
  95.      */
  96.     private $statut;
  97.     /**
  98.      * @ORM\Column(type="datetime")
  99.      */
  100.     private $statutDate;
  101.     /**
  102.      * @ORM\Column(type="string", length=255, nullable=true)
  103.      */
  104.     private $resetPassword;
  105.     /**
  106.      * @ORM\Column(type="datetime", nullable=true)
  107.      */
  108.     private $resetPasswordDate;
  109.     /**
  110.      * @ORM\Column(type="boolean")
  111.      */
  112.     private $publication;
  113.     /**
  114.      * @ORM\Column(type="datetime")
  115.      */
  116.     private $createdAt;
  117.     public function __construct()
  118.     {
  119.         $this->structures = new ArrayCollection();
  120.         $this->productionsCineAudio = new ArrayCollection();
  121.         $this->productionsCom = new ArrayCollection();
  122.         $this->prestatairesTechniques = new ArrayCollection();
  123.         $this->prestatairesLogistiques = new ArrayCollection();
  124.         $this->roles = ["ROLE_USER"];
  125.         $this->actions = new ArrayCollection();
  126.         $this->statut  'création';
  127.         $this->publication  0;
  128.         $this->statutDate = new \DateTime();
  129.     }
  130.     public function getId(): ?int
  131.     {
  132.         return $this->id;
  133.     }
  134.     /**
  135.      * @see UserInterface
  136.      */
  137.     public function getRoles(): array
  138.     {
  139.         $roles $this->roles;
  140.         // guarantee every user at least has ROLE_USER
  141.         $roles[] = 'ROLE_USER';
  142.         return array_unique($roles);
  143.     }
  144.     public function setRoles(array $roles): self
  145.     {
  146.         $this->roles $roles;
  147.         return $this;
  148.     }
  149.     public function getType(): ?string
  150.     {
  151.         return $this->type;
  152.     }
  153.     public function setType(string $type): self
  154.     {
  155.         $this->type $type;
  156.         return $this;
  157.     }
  158.     public function getUsername(): ?string
  159.     {
  160.         return $this->email;
  161.     }
  162.     public function setUsername(string $username): self
  163.     {
  164.         $this->username $username;
  165.         return $this;
  166.     }
  167.     public function getEmail(): ?string
  168.     {
  169.         return $this->email;
  170.     }
  171.     public function setEmail(string $email): self
  172.     {
  173.         $this->email $email;
  174.         return $this;
  175.     }
  176.     public function getPassword(): ?string
  177.     {
  178.         return $this->password;
  179.     }
  180.     public function setPassword(string $password): self
  181.     {
  182.         $this->password $password;
  183.         return $this;
  184.     }
  185.     public function getConfirmPassword()
  186.     {
  187.         return $this->confirm_password;
  188.     }
  189.     public function setConfirmPassword($confirm_password): void
  190.     {
  191.         $this->confirm_password $confirm_password;
  192.     }
  193.     public function getAccepteBdd(): ?bool
  194.     {
  195.         return $this->accepteBdd;
  196.     }
  197.     public function setAccepteBdd(bool $accepteBdd): self
  198.     {
  199.         $this->accepteBdd $accepteBdd;
  200.         return $this;
  201.     }
  202.     public function getAccepteTransmission(): ?bool
  203.     {
  204.         return $this->accepteTransmission;
  205.     }
  206.     public function setAccepteTransmission(?bool $accepteTransmission): self
  207.     {
  208.         $this->accepteTransmission $accepteTransmission;
  209.         return $this;
  210.     }
  211.     public function getAccepteDroitRetrait(): ?bool
  212.     {
  213.         return $this->accepteDroitRetrait;
  214.     }
  215.     public function setAccepteDroitRetrait(bool $accepteDroitRetrait): self
  216.     {
  217.         $this->accepteDroitRetrait $accepteDroitRetrait;
  218.         return $this;
  219.     }
  220.     public function eraseCredentials()
  221.     {
  222.     }
  223.     public function getSalt(){
  224.         return null;
  225.     }
  226.     /**
  227.      * @return Collection|Structure[]
  228.      */
  229.     public function getStructures(): Collection
  230.     {
  231.         return $this->structures;
  232.     }
  233.     public function addStructure(Structure $structure): self
  234.     {
  235.         if (!$this->structures->contains($structure)) {
  236.             $this->structures[] = $structure;
  237.             $structure->setUser($this);
  238.         }
  239.         return $this;
  240.     }
  241.     public function removeStructure(Structure $structure): self
  242.     {
  243.         if ($this->structures->contains($structure)) {
  244.             $this->structures->removeElement($structure);
  245.             // set the owning side to null (unless already changed)
  246.             if ($structure->getUser() === $this) {
  247.                 $structure->setUser(null);
  248.             }
  249.         }
  250.         return $this;
  251.     }
  252.     /**
  253.      * @return Collection|ProductionCineAudio[]
  254.      */
  255.     public function getProductionsCineAudio(): Collection
  256.     {
  257.         return $this->productionsCineAudio;
  258.     }
  259.     public function addProductionCineAudio(ProductionCineAudio $productionCineAudio): self
  260.     {
  261.         if (!$this->productionsCineAudio->contains($productionCineAudio)) {
  262.             $this->productionsCineAudio[] = $productionCineAudio;
  263.             $productionCineAudio->setUser($this);
  264.         }
  265.         return $this;
  266.     }
  267.     public function removeProductionCineAudio(ProductionCineAudio $productionCineAudio): self
  268.     {
  269.         if ($this->productionsCineAudio->contains($productionCineAudio)) {
  270.             $this->productionsCineAudio->removeElement($productionCineAudio);
  271.             // set the owning side to null (unless already changed)
  272.             if ($productionCineAudio->getUser() === $this) {
  273.                 $productionCineAudio->setUser(null);
  274.             }
  275.         }
  276.         return $this;
  277.     }
  278.     /**
  279.      * @return Collection|ProductionCom[]
  280.      */
  281.     public function getProductionsCom(): Collection
  282.     {
  283.         return $this->productionsCom;
  284.     }
  285.     public function addProductionCom(ProductionCom $productionCom): self
  286.     {
  287.         if (!$this->productionsCom->contains($productionCom)) {
  288.             $this->productionsCom[] = $productionCom;
  289.             $productionCom->setUser($this);
  290.         }
  291.         return $this;
  292.     }
  293.     public function removeProductionCom(ProductionCom $productionCom): self
  294.     {
  295.         if ($this->productionsCom->contains($productionCom)) {
  296.             $this->productionsCom->removeElement($productionCom);
  297.             // set the owning side to null (unless already changed)
  298.             if ($productionCom->getUser() === $this) {
  299.                 $productionCom->setUser(null);
  300.             }
  301.         }
  302.         return $this;
  303.     }
  304.     /**
  305.      * @return Collection|PrestataireTechnique[]
  306.      */
  307.     public function getPrestatairesTechniques(): Collection
  308.     {
  309.         return $this->prestatairesTechniques;
  310.     }
  311.     public function addPrestataireTechnique(PrestataireTechnique $prestatairesTechniques): self
  312.     {
  313.         if (!$this->prestatairesTechniques->contains($prestatairesTechniques)) {
  314.             $this->prestatairesTechniques[] = $prestatairesTechniques;
  315.             $prestatairesTechniques->setUser($this);
  316.         }
  317.         return $this;
  318.     }
  319.     public function removePrestataireTechnique(PrestataireTechnique $prestatairesTechniques): self
  320.     {
  321.         if ($this->prestatairesTechniques->contains($prestatairesTechniques)) {
  322.             $this->prestatairesTechniques->removeElement($prestatairesTechniques);
  323.             // set the owning side to null (unless already changed)
  324.             if ($prestatairesTechniques->getUser() === $this) {
  325.                 $prestatairesTechniques->setUser(null);
  326.             }
  327.         }
  328.         return $this;
  329.     }
  330.     /**
  331.      * @return Collection|PrestataireLogistique[]
  332.      */
  333.     public function getPrestatairesLogistiques(): Collection
  334.     {
  335.         return $this->prestatairesLogistiques;
  336.     }
  337.     public function addPrestataireLogistique(PrestataireLogistique $prestatairesLogistiques): self
  338.     {
  339.         if (!$this->prestatairesLogistiques->contains($prestatairesLogistiques)) {
  340.             $this->prestatairesLogistiques[] = $prestatairesLogistiques;
  341.             $prestatairesLogistiques->setUser($this);
  342.         }
  343.         return $this;
  344.     }
  345.     public function removePrestataireLogistique(PrestataireLogistique $prestatairesLogistiques): self
  346.     {
  347.         if ($this->prestatairesLogistiques->contains($prestatairesLogistiques)) {
  348.             $this->prestatairesLogistiques->removeElement($prestatairesLogistiques);
  349.             // set the owning side to null (unless already changed)
  350.             if ($prestatairesLogistiques->getUser() === $this) {
  351.                 $prestatairesLogistiques->setUser(null);
  352.             }
  353.         }
  354.         return $this;
  355.     }
  356.     /**
  357.      * @return Collection|Action[]
  358.      */
  359.     public function getActions(): Collection
  360.     {
  361.         return $this->actions;
  362.     }
  363.     public function addAction(Action $action): self
  364.     {
  365.         if (!$this->actions->contains($action)) {
  366.             $this->actions[] = $action;
  367.             $action->setUser($this);
  368.         }
  369.         return $this;
  370.     }
  371.     public function removeAction(Action $action): self
  372.     {
  373.         if ($this->actions->contains($action)) {
  374.             $this->actions->removeElement($action);
  375.             // set the owning side to null (unless already changed)
  376.             if ($action->getUser() === $this) {
  377.                 $action->setUser(null);
  378.             }
  379.         }
  380.         return $this;
  381.     }
  382.     public function getStatut(): ?string
  383.     {
  384.         return $this->statut;
  385.     }
  386.     public function setStatut(string $statut): self
  387.     {
  388.         $this->statut $statut;
  389.         return $this;
  390.     }
  391.     public function getStatutDate(): ?\DateTimeInterface
  392.     {
  393.         return $this->statutDate;
  394.     }
  395.     public function setStatutDate(\DateTimeInterface $statutDate): self
  396.     {
  397.         $this->statutDate $statutDate;
  398.         return $this;
  399.     }
  400.     public function getResetPassword(): ?string
  401.     {
  402.         return $this->resetPassword;
  403.     }
  404.     public function setResetPassword(?string $resetPassword): self
  405.     {
  406.         $this->resetPassword $resetPassword;
  407.         return $this;
  408.     }
  409.     public function getResetPasswordDate(): ?\DateTimeInterface
  410.     {
  411.         return $this->resetPasswordDate;
  412.     }
  413.     public function setResetPasswordDate(?\DateTimeInterface $resetPasswordDate): self
  414.     {
  415.         $this->resetPasswordDate $resetPasswordDate;
  416.         return $this;
  417.     }
  418.     public function getPublication(): ?bool
  419.     {
  420.         return $this->publication;
  421.     }
  422.     public function setPublication(bool $publication): self
  423.     {
  424.         $this->publication $publication;
  425.         return $this;
  426.     }
  427.     public function getCreatedAt(): ?\DateTimeInterface
  428.     {
  429.         return $this->createdAt;
  430.     }
  431.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  432.     {
  433.         $this->createdAt $createdAt;
  434.         return $this;
  435.     }
  436. }