src/Entity/Site.php line 25

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SiteRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\HttpFoundation\File\File;
  8. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  9. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. use Serializable;
  12. /**
  13.  * @ORM\Entity(repositoryClass=SiteRepository::class)
  14.  * @Vich\Uploadable
  15.  * @UniqueEntity(
  16.  *      fields={"email"},
  17.  *      message="Ce mail est déjà utilisé."
  18.  * )
  19.  * @UniqueEntity(fields={"telephone"},message="Ce téléphone est déjà utilisé." )
  20.  * @UniqueEntity(fields={"wording"},message="Ce nom est déjà utilisé." )
  21.  */
  22. class Site implements Serializable
  23. {
  24.     /**
  25.      * @ORM\Id
  26.      * @ORM\GeneratedValue
  27.      * @ORM\Column(type="integer")
  28.      */
  29.     private $id;
  30.     /**
  31.      * @ORM\Column(type="text")
  32.      */
  33.     private $wording;
  34.     /**
  35.      * @ORM\Column(type="text")
  36.      */
  37.     private $address;
  38.      /**
  39.      * @ORM\Column(type="string", length=255,nullable=true)
  40.      * @Assert\Email(message = "L'email '{{ value }}' n'est pas valide.")
  41.      */
  42.     private $email;
  43.     /**
  44.      * @ORM\Column(type="string", length=40)
  45.      * @Assert\Length(min=10,minMessage = "La taille minimum doit être de {{ limit }} caractères")
  46.      */
  47.     private $telephone;
  48.     /**
  49.      * @ORM\Column(type="text")
  50.      */
  51.     private $director;
  52.     /**
  53.      * @ORM\OneToMany(targetEntity=Session::class, mappedBy="site", orphanRemoval=true)
  54.      */
  55.     private $sessions;
  56.     /**
  57.      * @Doctrine\ORM\Mapping\Column(type="string", length=255, nullable=true)
  58.      */
  59.     private $image;
  60.     /**
  61.      * @Vich\UploadableField(mapping="cachet_site", fileNameProperty="image")
  62.      */
  63.     private $fichier;
  64.     /**
  65.      * @Doctrine\ORM\Mapping\Column(type="string", length=255, nullable=true)
  66.      */
  67.     private $imageCachet;
  68.     /**
  69.      * @Vich\UploadableField(mapping="cachet_site", fileNameProperty="imageCachet")
  70.      */
  71.     private $fichierCachet;
  72.     /**
  73.      * @ORM\Column(type="string", length=255)
  74.      */
  75.     private $titre;
  76.     /**
  77.      * @ORM\Column(type="string", length=1)
  78.      */
  79.     private $sexe;
  80.    /**
  81.      * @Doctrine\ORM\Mapping\Column(type="string", length=255, nullable=true)
  82.      */
  83.     private $map;
  84.     /**
  85.      * @Vich\UploadableField(mapping="signature_site", fileNameProperty="map")
  86.      */
  87.     private $fichiermap;
  88.     /**
  89.      * @ORM\Column(type="datetime_immutable", nullable=true)
  90.      */
  91.     private $updateAt;
  92.     /**
  93.      * @ORM\Column(type="string", nullable=true)
  94.      */
  95.     private $departement;
  96.     /**
  97.      * @ORM\OneToMany(targetEntity=User::class, mappedBy="site")
  98.      */
  99.     private $users;
  100.     /**
  101.      * @ORM\OneToMany(targetEntity=CalendarEvent::class, mappedBy="site")
  102.      */
  103.     private $calendarEvents;
  104.     /**
  105.      * @ORM\OneToMany(targetEntity=Diplome::class, mappedBy="site")
  106.      */
  107.     private $diplomes;
  108.     /**
  109.      * @ORM\OneToMany(targetEntity=Inscrit::class, mappedBy="site")
  110.      */
  111.     private $inscrits;
  112.     /**
  113.      * @ORM\OneToMany(targetEntity=Message::class, mappedBy="site")
  114.      */
  115.     private $messages;
  116.     /**
  117.      * @Doctrine\ORM\Mapping\Column(type="string", length=255, nullable=true)
  118.      */
  119.     private $cachetSignature;
  120.     /**
  121.      * @Vich\UploadableField(mapping="signature_site_cachet", fileNameProperty="cachetSignature")
  122.      */
  123.     private $fichiCachetSignature;
  124.     /**
  125.      * @ORM\OneToMany(targetEntity=EnteteFacture::class, mappedBy="site")
  126.      */
  127.     private $enteteFactures;
  128.     
  129.     /**
  130.      * @ORM\OneToMany(targetEntity=EnteteDevis::class, mappedBy="site")
  131.      */
  132.     private $enteteDevis;
  133.      /**
  134.      * @ORM\OneToMany(targetEntity=DemandeDevisEntete::class, mappedBy="site")
  135.      */
  136.     private $demandeDevisEntetes;
  137.     /**
  138.      * @ORM\OneToMany(targetEntity=DemandePro::class, mappedBy="site")
  139.      */
  140.     private $demandePros;
  141.     public function __construct()
  142.     {
  143.         $this->sessions = new ArrayCollection();
  144.         $this->users = new ArrayCollection();
  145.         $this->calendarEvents = new ArrayCollection();
  146.         $this->diplomes = new ArrayCollection();
  147.         $this->inscrits = new ArrayCollection();
  148.         $this->messages = new ArrayCollection();
  149.         $this->enteteFactures = new ArrayCollection();
  150.         $this->enteteDevis = new ArrayCollection();
  151.         $this->demandeDevisEntetes = new ArrayCollection();
  152.         $this->demandePros = new ArrayCollection();
  153.     }
  154.     public function getId(): ?int
  155.     {
  156.         return $this->id;
  157.     }
  158.     public function getWording(): ?string
  159.     {
  160.         return $this->wording;
  161.     }
  162.     public function setWording(string $wording): self
  163.     {
  164.         $this->wording $wording;
  165.         return $this;
  166.     }
  167.     public function getAddress(): ?string
  168.     {
  169.         return $this->address;
  170.     }
  171.     public function setAddress(string $address): self
  172.     {
  173.         $this->address $address;
  174.         return $this;
  175.     }
  176.     public function getTelephone(): ?string
  177.     {
  178.         return $this->telephone;
  179.     }
  180.     public function setTelephone(string $telephone): self
  181.     {
  182.         $this->telephone $telephone;
  183.         return $this;
  184.     }
  185.     public function getDirector(): ?string
  186.     {
  187.         return $this->director;
  188.     }
  189.     public function setDirector(string $director): self
  190.     {
  191.         $this->director $director;
  192.         return $this;
  193.     }
  194.     public function getEmail(): ?string
  195.     {
  196.         return $this->email;
  197.     }
  198.     public function setEmail(string $email): self
  199.     {
  200.         $this->email $email;
  201.         return $this;
  202.     }
  203.     /**
  204.      * @return Collection<int, Session>
  205.      */
  206.     public function getSessions(): Collection
  207.     {
  208.         return $this->sessions;
  209.     }
  210.     public function addSession(Session $session): self
  211.     {
  212.         if (!$this->sessions->contains($session)) {
  213.             $this->sessions[] = $session;
  214.             $session->setSite($this);
  215.         }
  216.         return $this;
  217.     }
  218.     public function removeSession(Session $session): self
  219.     {
  220.         if ($this->sessions->removeElement($session)) {
  221.             // set the owning side to null (unless already changed)
  222.             if ($session->getSite() === $this) {
  223.                 $session->setSite(null);
  224.             }
  225.         }
  226.         return $this;
  227.     }
  228.     public function setFichier(?File $image null)
  229.     {
  230.         $this->fichier $image;
  231.         if ($image) {
  232.             $this->updateAt = new \DateTimeImmutable();
  233.         }
  234.     }
  235.     public function getFichier()
  236.     {
  237.         return $this->fichier;
  238.     }
  239.     public function setImage($image)
  240.     {
  241.         $this->image $image;
  242.     }
  243.     public function getImage()
  244.     {
  245.         return $this->image;
  246.     }
  247.     public function setFichierMap(?File $imageCachet null)
  248.     {
  249.         $this->fichiermap $imageCachet;
  250.         if ($imageCachet) {
  251.             $this->updateAt = new \DateTimeImmutable();
  252.         }
  253.     }
  254.     public function getFichierMap()
  255.     {
  256.         return $this->fichiermap;
  257.     }
  258.     public function setMap($image)
  259.     {
  260.         $this->map $image;
  261.     }
  262.     public function getMap()
  263.     {
  264.         return $this->map;
  265.     }
  266.     public function getTitre(): ?string
  267.     {
  268.         return $this->titre;
  269.     }
  270.     public function setTitre(string $titre): self
  271.     {
  272.         $this->titre $titre;
  273.         return $this;
  274.     }
  275.     public function getSexe(): ?string
  276.     {
  277.         return $this->sexe;
  278.     }
  279.     public function setSexe(string $sexe): self
  280.     {
  281.         $this->sexe $sexe;
  282.         return $this;
  283.     }
  284.     public function setFichierCachet(?File $imageCachet null)
  285.     {
  286.         $this->fichierCachet $imageCachet;
  287.         if ($imageCachet) {
  288.             $this->updateAt = new \DateTimeImmutable();
  289.         }
  290.     }
  291.     public function getFichierCachet()
  292.     {
  293.         return $this->fichierCachet;
  294.     }
  295.     public function setImageCachet($image)
  296.     {
  297.         $this->imageCachet $image;
  298.     }
  299.     public function getImageCachet()
  300.     {
  301.         return $this->imageCachet;
  302.     }
  303.     public function getUpdateAt(): ?\DateTimeImmutable
  304.     {
  305.         return $this->updateAt;
  306.     }
  307.     public function setUpdateAt(?\DateTimeImmutable $updateAt): self
  308.     {
  309.         $this->updateAt $updateAt;
  310.         return $this;
  311.     }
  312.     public function getDepartement(): ?string
  313.     {
  314.         return $this->departement;
  315.     }
  316.     public function setDepartement(?string $departement): self
  317.     {
  318.         $this->departement $departement;
  319.         return $this;
  320.     }
  321.     /**
  322.      * @return Collection<int, User>
  323.      */
  324.     public function getUsers(): Collection
  325.     {
  326.         return $this->users;
  327.     }
  328.     public function addUser(User $user): self
  329.     {
  330.         if (!$this->users->contains($user)) {
  331.             $this->users[] = $user;
  332.             $user->setSite($this);
  333.         }
  334.         return $this;
  335.     }
  336.     public function removeUser(User $user): self
  337.     {
  338.         if ($this->users->removeElement($user)) {
  339.             // set the owning side to null (unless already changed)
  340.             if ($user->getSite() === $this) {
  341.                 $user->setSite(null);
  342.             }
  343.         }
  344.         return $this;
  345.     }
  346.     /**
  347.      * @return Collection<int, CalendarEvent>
  348.      */
  349.     public function getCalendarEvents(): Collection
  350.     {
  351.         return $this->calendarEvents;
  352.     }
  353.     public function addCalendarEvent(CalendarEvent $calendarEvent): self
  354.     {
  355.         if (!$this->calendarEvents->contains($calendarEvent)) {
  356.             $this->calendarEvents[] = $calendarEvent;
  357.             $calendarEvent->setSite($this);
  358.         }
  359.         return $this;
  360.     }
  361.     public function removeCalendarEvent(CalendarEvent $calendarEvent): self
  362.     {
  363.         if ($this->calendarEvents->removeElement($calendarEvent)) {
  364.             // set the owning side to null (unless already changed)
  365.             if ($calendarEvent->getSite() === $this) {
  366.                 $calendarEvent->setSite(null);
  367.             }
  368.         }
  369.         return $this;
  370.     }
  371.     /**
  372.      * @return Collection<int, Diplome>
  373.      */
  374.     public function getDiplomes(): Collection
  375.     {
  376.         return $this->diplomes;
  377.     }
  378.     public function addDiplome(Diplome $diplome): self
  379.     {
  380.         if (!$this->diplomes->contains($diplome)) {
  381.             $this->diplomes[] = $diplome;
  382.             $diplome->setSite($this);
  383.         }
  384.         return $this;
  385.     }
  386.     public function removeDiplome(Diplome $diplome): self
  387.     {
  388.         if ($this->diplomes->removeElement($diplome)) {
  389.             // set the owning side to null (unless already changed)
  390.             if ($diplome->getSite() === $this) {
  391.                 $diplome->setSite(null);
  392.             }
  393.         }
  394.         return $this;
  395.     }
  396.     /**
  397.      * @return Collection<int, Inscrit>
  398.      */
  399.     public function getInscrits(): Collection
  400.     {
  401.         return $this->inscrits;
  402.     }
  403.     public function addInscrit(Inscrit $inscrit): self
  404.     {
  405.         if (!$this->inscrits->contains($inscrit)) {
  406.             $this->inscrits[] = $inscrit;
  407.             $inscrit->setSite($this);
  408.         }
  409.         return $this;
  410.     }
  411.     public function removeInscrit(Inscrit $inscrit): self
  412.     {
  413.         if ($this->inscrits->removeElement($inscrit)) {
  414.             // set the owning side to null (unless already changed)
  415.             if ($inscrit->getSite() === $this) {
  416.                 $inscrit->setSite(null);
  417.             }
  418.         }
  419.         return $this;
  420.     }
  421.     /**
  422.      * @return Collection<int, Message>
  423.      */
  424.     public function getMessages(): Collection
  425.     {
  426.         return $this->messages;
  427.     }
  428.     public function addMessage(Message $message): self
  429.     {
  430.         if (!$this->messages->contains($message)) {
  431.             $this->messages[] = $message;
  432.             $message->setSite($this);
  433.         }
  434.         return $this;
  435.     }
  436.     public function removeMessage(Message $message): self
  437.     {
  438.         if ($this->messages->removeElement($message)) {
  439.             // set the owning side to null (unless already changed)
  440.             if ($message->getSite() === $this) {
  441.                 $message->setSite(null);
  442.             }
  443.         }
  444.         return $this;
  445.     }
  446.     public function setFichiCachetSignature(?File $imageCachet null)
  447.     {
  448.         $this->fichiCachetSignature $imageCachet;
  449.         if ($imageCachet) {
  450.             $this->updateAt = new \DateTimeImmutable();
  451.         }
  452.     }
  453.     public function getFichiCachetSignature()
  454.     {
  455.         return $this->fichiCachetSignature;
  456.     }
  457.     public function setCachetSignature($image)
  458.     {
  459.         $this->cachetSignature $image;
  460.     }
  461.     public function getCachetSignature()
  462.     {
  463.         return $this->cachetSignature;
  464.     }
  465.     /**
  466.      * @return Collection<int, EnteteFacture>
  467.      */
  468.     public function getEnteteFactures(): Collection
  469.     {
  470.         return $this->enteteFactures;
  471.     }
  472.     public function addEnteteFacture(EnteteFacture $enteteFacture): self
  473.     {
  474.         if (!$this->enteteFactures->contains($enteteFacture)) {
  475.             $this->enteteFactures[] = $enteteFacture;
  476.             $enteteFacture->setSite($this);
  477.         }
  478.         return $this;
  479.     }
  480.     public function removeEnteteFacture(EnteteFacture $enteteFacture): self
  481.     {
  482.         if ($this->enteteFactures->removeElement($enteteFacture)) {
  483.             // set the owning side to null (unless already changed)
  484.             if ($enteteFacture->getSite() === $this) {
  485.                 $enteteFacture->setSite(null);
  486.             }
  487.         }
  488.         return $this;
  489.     }
  490.     /**
  491.      * @return Collection<int, EnteteDevis>
  492.      */
  493.     public function getEnteteDevis(): Collection
  494.     {
  495.         return $this->enteteDevis;
  496.     }
  497.     public function addEnteteDevi(EnteteDevis $enteteDevi): self
  498.     {
  499.         if (!$this->enteteDevis->contains($enteteDevi)) {
  500.             $this->enteteDevis[] = $enteteDevi;
  501.             $enteteDevi->setSite($this);
  502.         }
  503.         return $this;
  504.     }
  505.     public function removeEnteteDevi(EnteteDevis $enteteDevi): self
  506.     {
  507.         if ($this->enteteDevis->removeElement($enteteDevi)) {
  508.             // set the owning side to null (unless already changed)
  509.             if ($enteteDevi->getSite() === $this) {
  510.                 $enteteDevi->setSite(null);
  511.             }
  512.         }
  513.         return $this;
  514.     }
  515.     /**
  516.      * @return Collection<int, DemandeDevisEntete>
  517.      */
  518.     public function getDemandeDevisEntetes(): Collection
  519.     {
  520.         return $this->demandeDevisEntetes;
  521.     }
  522.     public function addDemandeDevisEntetes(DemandeDevisEntete $demandeDevisEntetes): self
  523.     {
  524.         if (!$this->demandeDevisEntetes->contains($demandeDevisEntetes)) {
  525.             $this->demandeDevisEntetes[] = $demandeDevisEntetes;
  526.             $demandeDevisEntetes->setSite($this);
  527.         }
  528.         return $this;
  529.     }
  530.     public function removeDemandeDevisEntetes(DemandeDevisEntete $demandeDevisEntetes): self
  531.     {
  532.         if ($this->demandeDevisEntetes->removeElement($demandeDevisEntetes)) {
  533.             // set the owning side to null (unless already changed)
  534.             if ($demandeDevisEntetes->getSite() === $this) {
  535.                 $demandeDevisEntetes->setSite(null);
  536.             }
  537.         }
  538.         return $this;
  539.     }
  540.     public function serialize()
  541.     {
  542.         $this->fichier base64_encode($this->fichier);
  543.         $this->fichierCachet base64_encode($this->fichierCachet);
  544.         $this->fichiermap base64_encode($this->fichiermap);
  545.         $this->fichiCachetSignature base64_encode($this->fichiCachetSignature);
  546.     }
  547.     public function unserialize($serialized)
  548.     {
  549.         $this->fichier base64_decode($this->fichier);
  550.         $this->fichierCachet base64_decode($this->fichierCachet);
  551.         $this->fichiermap base64_decode($this->fichiermap);
  552.         $this->fichiCachetSignature base64_decode($this->fichiCachetSignature);
  553.     }
  554.     /**
  555.      * @return Collection<int, DemandePro>
  556.      */
  557.     public function getDemandePros(): Collection
  558.     {
  559.         return $this->demandePros;
  560.     }
  561.     public function addDemandePro(DemandePro $demandePro): self
  562.     {
  563.         if (!$this->demandePros->contains($demandePro)) {
  564.             $this->demandePros[] = $demandePro;
  565.             $demandePro->setSite($this);
  566.         }
  567.         return $this;
  568.     }
  569.     public function removeDemandePro(DemandePro $demandePro): self
  570.     {
  571.         if ($this->demandePros->removeElement($demandePro)) {
  572.             // set the owning side to null (unless already changed)
  573.             if ($demandePro->getSite() === $this) {
  574.                 $demandePro->setSite(null);
  575.             }
  576.         }
  577.         return $this;
  578.     }
  579. }