src/Entity/Client.php line 28

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 PhpOffice\PhpWord\Reader\RTF\Document;
  7. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. use ApiPlatform\Core\Annotation\ApiFilter;
  11. use ApiPlatform\Core\Annotation\ApiResource;
  12. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
  13. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  14. /**
  15.  * @ORM\Entity(repositoryClass="App\Repository\ClientRepository")
  16.  * @UniqueEntity(fields="nom", message="le nom du client existe deja")
  17.  *  * @ApiResource(attributes={
  18.  *     "normalization_context"={"groups"={"client-list"}},
  19.  *     "filters"= { "several","client.search"},
  20.  *     "pagination_client_enabled"=true
  21.  * })
  22.  * @ApiFilter(OrderFilter::class, properties={"id": "DESC", "nom": "ASC"}, arguments={"orderParameterName" : "order"})
  23.  * @ApiFilter(SearchFilter::class, properties={"nom": "partial", "dirigeant": "partial"})
  24.  */
  25. class Client
  26. {
  27.     /**
  28.      * @var int
  29.      *
  30.      * @ORM\Column(name="id", type="integer")
  31.      * @ORM\Id
  32.      * @ORM\GeneratedValue(strategy="AUTO")
  33.      * @Groups({"client-list","auth-token","auth-user-list","mailling","evenement","pressroom","suivit","mots-cles","suivi","parution","actualite","liste_parution"})
  34.      */
  35.     private $id;
  36.     /**
  37.      * @ORM\Column(type="string", length=255)
  38.      * @Assert\NotBlank()
  39.      * @Groups({"client-list","auth-token","auth-user-list","mailling","evenement","pressroom","suivit","mots-cles","suivi","parution","actualite","liste_parution"})
  40.      */
  41.     private $nom;
  42.     /**
  43.      * @var string $adresseGenerique
  44.      * @ORM\Column(name="adresse_generique", type="string", length=255, nullable=false,nullable=true)
  45.      * @Groups({"client-list","auth-token","auth-user-list"})
  46.      */
  47.     private $adresseGenerique;
  48.     /**
  49.      * @var string $adresseCoupure
  50.      * @ORM\Column(name="adresse_coupure", type="string", length=255, nullable=false,nullable=true)
  51.      * @Groups({"client-list","auth-token","auth-user-list"})
  52.      */
  53.     private $adresseCoupure;
  54.     /**
  55.      * @ORM\Column(type="boolean")
  56.      * @Groups({"client-list","suivi_action","mots-cles"})
  57.      */
  58.     private $actuel;
  59.     /**
  60.      * @ORM\Column(name="ancien_id", type="integer",nullable=true)
  61.      * @Groups({"client-list","suivi_action","mailling","suivi","parution"})
  62.      */
  63.     private $ancienId;
  64.     /**
  65.      * @ORM\Column(name="dirigeant",type="string",length=255, nullable=true)
  66.      * @Groups({"client-list"})
  67.      */
  68.     private $dirigeant;
  69.     /**
  70.      * @ORM\OneToOne(targetEntity="App\Entity\Logo")
  71.      * @ORM\JoinColumn(name="logo_id",referencedColumnName="id", nullable=true)
  72.      * @Groups({"client-list","mailling"})
  73.      */
  74.     private $logo;
  75.     /**
  76.      * @ORM\OneToMany(targetEntity="App\Entity\ClientRoleUser", mappedBy="client")
  77.      * @Groups({"client-list"})
  78.      */
  79.     private $rolesUserClient;
  80.     /**
  81.      * @ORM\OneToMany(targetEntity="App\Entity\Mailling", mappedBy="client")
  82.      */
  83.     private $maillings;
  84.     /**
  85.      * @ORM\OneToMany(targetEntity="App\Entity\ClientPersonne", mappedBy="client")
  86.      * @Groups({"client-list","mailling"})
  87.      */
  88.     private $personnes;
  89.     /**
  90.      *@ORM\OneToMany(targetEntity="App\Entity\Evenement", mappedBy="client")
  91.      * @Groups({"mailling"})
  92.      */
  93.     private $evenements;
  94.     /**
  95.      * @ORM\OneToOne(targetEntity="Pressroom", inversedBy="client")
  96.      * @ORM\JoinColumn(name="pressroom_client", referencedColumnName="id", nullable= true)
  97.      */
  98.     private $pressroom;
  99.     /**
  100.      * @ORM\Column(name="date_entree",type="date",length=255, nullable=true)
  101.      * @Groups({"client-list"})
  102.      */
  103.     private $dateEntree;
  104.     /**
  105.      * @ORM\Column(name="date_sortie",type="date",length=255, nullable=true)
  106.      * @Groups({"client-list"})
  107.      */
  108.     private $dateSortie;
  109.     /**
  110.      * @ORM\Column(name="duree",type="integer", nullable=true)
  111.      * @Groups({"client-list"})
  112.      */
  113.     private $duree;
  114.     /**
  115.      * @ORM\Column(name="score",type="string", nullable=true)
  116.      * @Groups({"client-list"})
  117.      */
  118.     private $score;
  119.     /**
  120.      * @ORM\ManyToMany(targetEntity="App\Entity\MotsCles", mappedBy="client")
  121.      * @Groups({"client-list"})
  122.      */
  123.     private $motsCles;
  124.     /**
  125.      *@ORM\OneToMany(targetEntity="App\Entity\Documents", mappedBy="client")
  126.      * @Groups({"client-list"})
  127.      */
  128.     private $documents;
  129.     /**
  130.      * @ORM\OneToOne(targetEntity=Organisation::class, mappedBy="client", cascade={"persist", "remove"})
  131.      */
  132.     private $organisation;
  133.     /**
  134.      * @ORM\ManyToMany(targetEntity=CalendrierRedactionnel::class, mappedBy="clients")
  135.      */
  136.     private $calendrierRedactionnels;
  137.     /**
  138.      * @ORM\ManyToOne(targetEntity=Etat::class)
  139.      * @Groups({"client-list"})
  140.      */
  141.     private $etat;
  142.     /**
  143.      * @ORM\OneToMany(targetEntity=Membre::class, mappedBy="client")
  144.      * @Groups({"client-list","actualite"})
  145.      */
  146.     private $membres;
  147.     /**
  148.      * Client constructor.
  149.      */
  150.     public function __construct()
  151.     {
  152.         $this->rolesUserClient = new ArrayCollection();
  153.         $this->maillings = new ArrayCollection();
  154.         $this->personnes = new ArrayCollection();
  155.         $this->evenements = new ArrayCollection();
  156.         $this->motsCles = new ArrayCollection();
  157.         $this->documents = new ArrayCollection();
  158.         $this->calendrierRedactionnels = new ArrayCollection();
  159.         $this->membres = new ArrayCollection();
  160.     }
  161.     /**
  162.      * @return int
  163.      */
  164.     public function getId(): int
  165.     {
  166.         return $this->id;
  167.     }
  168.     /**
  169.      * @param int $id
  170.      */
  171.     public function setId(int $id): void
  172.     {
  173.         $this->id $id;
  174.     }
  175.     /**
  176.      * @return mixed
  177.      */
  178.     public function getNom()
  179.     {
  180.         return $this->nom;
  181.     }
  182.     /**
  183.      * @param mixed $nom
  184.      */
  185.     public function setNom($nom): void
  186.     {
  187.         $this->nom $nom;
  188.     }
  189.     public function getAdresseGenerique()
  190.     {
  191.         return $this->adresseGenerique;
  192.     }
  193.     /**
  194.      * @param string $adresseGenerique
  195.      */
  196.     public function setAdresseGenerique(string $adresseGenerique): void
  197.     {
  198.         $this->adresseGenerique $adresseGenerique;
  199.     }
  200.     public function getAdresseCoupure()
  201.     {
  202.         return $this->adresseCoupure;
  203.     }
  204.     /**
  205.      * @param string $adresseCoupure
  206.      */
  207.     public function setAdresseCoupure(string $adresseCoupure): void
  208.     {
  209.         $this->adresseCoupure $adresseCoupure;
  210.     }
  211.     /**
  212.      * @return mixed
  213.      */
  214.     public function getActuel()
  215.     {
  216.         return $this->actuel;
  217.     }
  218.     /**
  219.      * @param mixed $actuel
  220.      */
  221.     public function setActuel($actuel): void
  222.     {
  223.         $this->actuel $actuel;
  224.     }
  225.     /**
  226.      * @return mixed
  227.      */
  228.     public function getAncienId()
  229.     {
  230.         return $this->ancienId;
  231.     }
  232.     /**
  233.      * @param mixed $ancienId
  234.      */
  235.     public function setAncienId($ancienId): void
  236.     {
  237.         $this->ancienId $ancienId;
  238.     }
  239.     /**
  240.      * @return mixed
  241.      */
  242.     public function getDirigeant()
  243.     {
  244.         return $this->dirigeant;
  245.     }
  246.     /**
  247.      * @param mixed $dirigeant
  248.      */
  249.     public function setDirigeant($dirigeant): void
  250.     {
  251.         $this->dirigeant $dirigeant;
  252.     }
  253.     /**
  254.      * Set logo
  255.      *
  256.      * @param \App\Entity\Logo $logo
  257.      *
  258.      * @return Client
  259.      */
  260.     public function setLogo(\App\Entity\Logo $logo null)
  261.     {
  262.         $this->logo $logo;
  263.         return $this;
  264.     }
  265.     /**
  266.      * Get logo
  267.      *
  268.      * @return \App\Entity\Logo
  269.      */
  270.     public function getLogo()
  271.     {
  272.         return $this->logo;
  273.     }
  274.     /**
  275.      * Add rolesUserClient
  276.      *
  277.      * @param \App\Entity\ClientRoleUser $rolesUserClient
  278.      *
  279.      * @return Client
  280.      */
  281.     public function addRolesUserClient(\App\Entity\ClientRoleUser $rolesUserClient)
  282.     {
  283.         $this->rolesUserClient[] = $rolesUserClient;
  284.         return $this;
  285.     }
  286.     /**
  287.      * Remove rolesUserClient
  288.      *
  289.      * @param \App\Entity\ClientRoleUser $rolesUserClient
  290.      */
  291.     public function removeRolesUserClient(\App\Entity\ClientRoleUser $rolesUserClient)
  292.     {
  293.         $this->rolesUserClient->removeElement($rolesUserClient);
  294.     }
  295.     /**
  296.      * Get rolesUserClient
  297.      *
  298.      * @return \Doctrine\Common\Collections\Collection
  299.      */
  300.     public function getRolesUserClient()
  301.     {
  302.         return $this->rolesUserClient;
  303.     }
  304.     /**
  305.      * Add mailling
  306.      *
  307.      * @param \App\Entity\Mailling $mailling
  308.      *
  309.      * @return Client
  310.      */
  311.     public function addMailling(\App\Entity\Mailling $mailling)
  312.     {
  313.         $this->maillings[] = $mailling;
  314.         return $this;
  315.     }
  316.     /**
  317.      * Remove mailling
  318.      *
  319.      * @param \App\Entity\Mailling $mailling
  320.      */
  321.     public function removeMailling(\App\Entity\Mailling $mailling)
  322.     {
  323.         $this->maillings->removeElement($mailling);
  324.     }
  325.     /**
  326.      * @return Collection|Mailling[]
  327.      */
  328.     public function getMaillings(): Collection
  329.     {
  330.         return $this->maillings;
  331.     }
  332.     /**
  333.      * @return Collection|ClientPersonne[]
  334.      */
  335.     public function getPersonnes(): Collection
  336.     {
  337.         return $this->personnes;
  338.     }
  339.     public function addPersonne(ClientPersonne $personne): self
  340.     {
  341.         if (!$this->personnes->contains($personne)) {
  342.             $this->personnes[] = $personne;
  343.             $personne->setClient($this);
  344.         }
  345.         return $this;
  346.     }
  347.     public function removePersonne(ClientPersonne $personne): self
  348.     {
  349.         if ($this->personnes->contains($personne)) {
  350.             $this->personnes->removeElement($personne);
  351.             // set the owning side to null (unless already changed)
  352.             if ($personne->getClient() === $this) {
  353.                 $personne->setClient(null);
  354.             }
  355.         }
  356.         return $this;
  357.     }
  358.     /**
  359.      * @return Collection|Evenement[]
  360.      */
  361.     public function getEvenements(): Collection
  362.     {
  363.         return $this->evenements;
  364.     }
  365.     public function addEvenement(Evenement $evenement): self
  366.     {
  367.         if (!$this->evenements->contains($evenement)) {
  368.             $this->evenements[] = $evenement;
  369.             $evenement->setClient($this);
  370.         }
  371.         return $this;
  372.     }
  373.     public function removeEvenement(Evenement $evenement): self
  374.     {
  375.         if ($this->evenements->contains($evenement)) {
  376.             $this->evenements->removeElement($evenement);
  377.             // set the owning side to null (unless already changed)
  378.             if ($evenement->getClient() === $this) {
  379.                 $evenement->setClient(null);
  380.             }
  381.         }
  382.         return $this;
  383.     }
  384.     public function getPressroom(): ?Pressroom
  385.     {
  386.         return $this->pressroom;
  387.     }
  388.     public function setPressroom(?Pressroom $pressroom): self
  389.     {
  390.         $this->pressroom $pressroom;
  391.         return $this;
  392.     }
  393.     /**
  394.      * @return Collection|MotsCles[]
  395.      */
  396.     public function getMotsCles(): Collection
  397.     {
  398.         return $this->motsCles;
  399.     }
  400.     public function addMotsCle(MotsCles $motsCle): self
  401.     {
  402.         if (!$this->motsCles->contains($motsCle)) {
  403.             $this->motsCles[] = $motsCle;
  404.             $motsCle->addClient($this);
  405.         }
  406.         return $this;
  407.     }
  408.     public function removeMotsCle(MotsCles $motsCle): self
  409.     {
  410.         if ($this->motsCles->removeElement($motsCle)) {
  411.             $motsCle->removeClient($this);
  412.         }
  413.         return $this;
  414.     }
  415.     /**
  416.      * @return Collection|Document[]
  417.      */
  418.     public function getDocuments(): Collection
  419.     {
  420.         return $this->documents;
  421.     }
  422.     public function getDateEntree()
  423.     {
  424.         return $this->dateEntree;
  425.     }
  426.     public function addDocument(Documents $document): self
  427.     {
  428.         if (!$this->documents->contains($document)) {
  429.             $this->documents[] = $document;
  430.             $document->setClient($this);
  431.         }
  432.         return $this;
  433.     }
  434.     public function setDateEntree($dateEntree): void
  435.     {
  436.         $this->dateEntree $dateEntree;
  437.     }
  438.     public function removeDocument(Documents $document): self
  439.     {
  440.         if ($this->documents->contains($document)) {
  441.             $this->documents->removeElement($document);
  442.             // set the owning side to null (unless already changed)
  443.             if ($document->getClient() === $this) {
  444.                 $document->setClient(null);
  445.             }
  446.         }   return $this;
  447.     }
  448.     public function getDateSortie()
  449.     {
  450.         return $this->dateSortie;
  451.     }
  452.     public function setDateSortie($dateSortie): void
  453.     {
  454.         $this->dateSortie $dateSortie;
  455.     }
  456.     public function getDuree()
  457.     {
  458.         return $this->duree;
  459.     }
  460.     public function setDuree($duree): void
  461.     {
  462.         $this->duree $duree;
  463.     }
  464.     public function getScore()
  465.     {
  466.         return $this->score;
  467.     }
  468.     public function setScore($score): void
  469.     {
  470.         $this->score $score;
  471.     }
  472.     public function getOrganisation(): ?Organisation
  473.     {
  474.         return $this->organisation;
  475.     }
  476.     public function setOrganisation(?Organisation $organisation): self
  477.     {
  478.         $this->organisation $organisation;
  479.         // set (or unset) the owning side of the relation if necessary
  480.         $newClient null === $organisation null $this;
  481.         if ($organisation->getClient() !== $newClient) {
  482.             $organisation->setClient($newClient);
  483.         }
  484.         return $this;
  485.     }
  486.     /**
  487.      * @return Collection|CalendrierRedactionnel[]
  488.      */
  489.     public function getCalendrierRedactionnels(): Collection
  490.     {
  491.         return $this->calendrierRedactionnels;
  492.     }
  493.     public function addCalendrierRedactionnel(CalendrierRedactionnel $calendrierRedactionnel): self
  494.     {
  495.         if (!$this->calendrierRedactionnels->contains($calendrierRedactionnel)) {
  496.             $this->calendrierRedactionnels[] = $calendrierRedactionnel;
  497.             $calendrierRedactionnel->addClient($this);
  498.         }
  499.         return $this;
  500.     }
  501.     public function removeCalendrierRedactionnel(CalendrierRedactionnel $calendrierRedactionnel): self
  502.     {
  503.         if ($this->calendrierRedactionnels->removeElement($calendrierRedactionnel)) {
  504.             $calendrierRedactionnel->removeClient($this);
  505.         }
  506.         return $this;
  507.     }
  508.     public function getEtat(): ?Etat
  509.     {
  510.         return $this->etat;
  511.     }
  512.     public function setEtat(?Etat $etat): self
  513.     {
  514.         $this->etat $etat;
  515.         return $this;
  516.     }
  517.     /**
  518.      * @return Collection|Membre[]
  519.      */
  520.     public function getMembres(): Collection
  521.     {
  522.         return $this->membres;
  523.     }
  524.     public function removeMembre(Membre $membre): self
  525.     {
  526.         if ($this->membres->contains($membre)) {
  527.             $this->membres->removeElement($membre);
  528.             // set the owning side to null (unless already changed)
  529.             if ($membre->getClient() === $this) {
  530.                 $membre->setClient(null);
  531.             }
  532.         }   return $this;
  533.     }
  534. }