<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use PhpOffice\PhpWord\Reader\RTF\Document;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
/**
* @ORM\Entity(repositoryClass="App\Repository\ClientRepository")
* @UniqueEntity(fields="nom", message="le nom du client existe deja")
* * @ApiResource(attributes={
* "normalization_context"={"groups"={"client-list"}},
* "filters"= { "several","client.search"},
* "pagination_client_enabled"=true
* })
* @ApiFilter(OrderFilter::class, properties={"id": "DESC", "nom": "ASC"}, arguments={"orderParameterName" : "order"})
* @ApiFilter(SearchFilter::class, properties={"nom": "partial", "dirigeant": "partial"})
*/
class Client
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @Groups({"client-list","auth-token","auth-user-list","mailling","evenement","pressroom","suivit","mots-cles","suivi","parution","actualite","liste_parution"})
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
* @Assert\NotBlank()
* @Groups({"client-list","auth-token","auth-user-list","mailling","evenement","pressroom","suivit","mots-cles","suivi","parution","actualite","liste_parution"})
*/
private $nom;
/**
* @var string $adresseGenerique
* @ORM\Column(name="adresse_generique", type="string", length=255, nullable=false,nullable=true)
* @Groups({"client-list","auth-token","auth-user-list"})
*/
private $adresseGenerique;
/**
* @var string $adresseCoupure
* @ORM\Column(name="adresse_coupure", type="string", length=255, nullable=false,nullable=true)
* @Groups({"client-list","auth-token","auth-user-list"})
*/
private $adresseCoupure;
/**
* @ORM\Column(type="boolean")
* @Groups({"client-list","suivi_action","mots-cles"})
*/
private $actuel;
/**
* @ORM\Column(name="ancien_id", type="integer",nullable=true)
* @Groups({"client-list","suivi_action","mailling","suivi","parution"})
*/
private $ancienId;
/**
* @ORM\Column(name="dirigeant",type="string",length=255, nullable=true)
* @Groups({"client-list"})
*/
private $dirigeant;
/**
* @ORM\OneToOne(targetEntity="App\Entity\Logo")
* @ORM\JoinColumn(name="logo_id",referencedColumnName="id", nullable=true)
* @Groups({"client-list","mailling"})
*/
private $logo;
/**
* @ORM\OneToMany(targetEntity="App\Entity\ClientRoleUser", mappedBy="client")
* @Groups({"client-list"})
*/
private $rolesUserClient;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Mailling", mappedBy="client")
*/
private $maillings;
/**
* @ORM\OneToMany(targetEntity="App\Entity\ClientPersonne", mappedBy="client")
* @Groups({"client-list","mailling"})
*/
private $personnes;
/**
*@ORM\OneToMany(targetEntity="App\Entity\Evenement", mappedBy="client")
* @Groups({"mailling"})
*/
private $evenements;
/**
* @ORM\OneToOne(targetEntity="Pressroom", inversedBy="client")
* @ORM\JoinColumn(name="pressroom_client", referencedColumnName="id", nullable= true)
*/
private $pressroom;
/**
* @ORM\Column(name="date_entree",type="date",length=255, nullable=true)
* @Groups({"client-list"})
*/
private $dateEntree;
/**
* @ORM\Column(name="date_sortie",type="date",length=255, nullable=true)
* @Groups({"client-list"})
*/
private $dateSortie;
/**
* @ORM\Column(name="duree",type="integer", nullable=true)
* @Groups({"client-list"})
*/
private $duree;
/**
* @ORM\Column(name="score",type="string", nullable=true)
* @Groups({"client-list"})
*/
private $score;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\MotsCles", mappedBy="client")
* @Groups({"client-list"})
*/
private $motsCles;
/**
*@ORM\OneToMany(targetEntity="App\Entity\Documents", mappedBy="client")
* @Groups({"client-list"})
*/
private $documents;
/**
* @ORM\OneToOne(targetEntity=Organisation::class, mappedBy="client", cascade={"persist", "remove"})
*/
private $organisation;
/**
* @ORM\ManyToMany(targetEntity=CalendrierRedactionnel::class, mappedBy="clients")
*/
private $calendrierRedactionnels;
/**
* @ORM\ManyToOne(targetEntity=Etat::class)
* @Groups({"client-list"})
*/
private $etat;
/**
* @ORM\OneToMany(targetEntity=Membre::class, mappedBy="client")
* @Groups({"client-list","actualite"})
*/
private $membres;
/**
* Client constructor.
*/
public function __construct()
{
$this->rolesUserClient = new ArrayCollection();
$this->maillings = new ArrayCollection();
$this->personnes = new ArrayCollection();
$this->evenements = new ArrayCollection();
$this->motsCles = new ArrayCollection();
$this->documents = new ArrayCollection();
$this->calendrierRedactionnels = new ArrayCollection();
$this->membres = new ArrayCollection();
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @param int $id
*/
public function setId(int $id): void
{
$this->id = $id;
}
/**
* @return mixed
*/
public function getNom()
{
return $this->nom;
}
/**
* @param mixed $nom
*/
public function setNom($nom): void
{
$this->nom = $nom;
}
public function getAdresseGenerique()
{
return $this->adresseGenerique;
}
/**
* @param string $adresseGenerique
*/
public function setAdresseGenerique(string $adresseGenerique): void
{
$this->adresseGenerique = $adresseGenerique;
}
public function getAdresseCoupure()
{
return $this->adresseCoupure;
}
/**
* @param string $adresseCoupure
*/
public function setAdresseCoupure(string $adresseCoupure): void
{
$this->adresseCoupure = $adresseCoupure;
}
/**
* @return mixed
*/
public function getActuel()
{
return $this->actuel;
}
/**
* @param mixed $actuel
*/
public function setActuel($actuel): void
{
$this->actuel = $actuel;
}
/**
* @return mixed
*/
public function getAncienId()
{
return $this->ancienId;
}
/**
* @param mixed $ancienId
*/
public function setAncienId($ancienId): void
{
$this->ancienId = $ancienId;
}
/**
* @return mixed
*/
public function getDirigeant()
{
return $this->dirigeant;
}
/**
* @param mixed $dirigeant
*/
public function setDirigeant($dirigeant): void
{
$this->dirigeant = $dirigeant;
}
/**
* Set logo
*
* @param \App\Entity\Logo $logo
*
* @return Client
*/
public function setLogo(\App\Entity\Logo $logo = null)
{
$this->logo = $logo;
return $this;
}
/**
* Get logo
*
* @return \App\Entity\Logo
*/
public function getLogo()
{
return $this->logo;
}
/**
* Add rolesUserClient
*
* @param \App\Entity\ClientRoleUser $rolesUserClient
*
* @return Client
*/
public function addRolesUserClient(\App\Entity\ClientRoleUser $rolesUserClient)
{
$this->rolesUserClient[] = $rolesUserClient;
return $this;
}
/**
* Remove rolesUserClient
*
* @param \App\Entity\ClientRoleUser $rolesUserClient
*/
public function removeRolesUserClient(\App\Entity\ClientRoleUser $rolesUserClient)
{
$this->rolesUserClient->removeElement($rolesUserClient);
}
/**
* Get rolesUserClient
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getRolesUserClient()
{
return $this->rolesUserClient;
}
/**
* Add mailling
*
* @param \App\Entity\Mailling $mailling
*
* @return Client
*/
public function addMailling(\App\Entity\Mailling $mailling)
{
$this->maillings[] = $mailling;
return $this;
}
/**
* Remove mailling
*
* @param \App\Entity\Mailling $mailling
*/
public function removeMailling(\App\Entity\Mailling $mailling)
{
$this->maillings->removeElement($mailling);
}
/**
* @return Collection|Mailling[]
*/
public function getMaillings(): Collection
{
return $this->maillings;
}
/**
* @return Collection|ClientPersonne[]
*/
public function getPersonnes(): Collection
{
return $this->personnes;
}
public function addPersonne(ClientPersonne $personne): self
{
if (!$this->personnes->contains($personne)) {
$this->personnes[] = $personne;
$personne->setClient($this);
}
return $this;
}
public function removePersonne(ClientPersonne $personne): self
{
if ($this->personnes->contains($personne)) {
$this->personnes->removeElement($personne);
// set the owning side to null (unless already changed)
if ($personne->getClient() === $this) {
$personne->setClient(null);
}
}
return $this;
}
/**
* @return Collection|Evenement[]
*/
public function getEvenements(): Collection
{
return $this->evenements;
}
public function addEvenement(Evenement $evenement): self
{
if (!$this->evenements->contains($evenement)) {
$this->evenements[] = $evenement;
$evenement->setClient($this);
}
return $this;
}
public function removeEvenement(Evenement $evenement): self
{
if ($this->evenements->contains($evenement)) {
$this->evenements->removeElement($evenement);
// set the owning side to null (unless already changed)
if ($evenement->getClient() === $this) {
$evenement->setClient(null);
}
}
return $this;
}
public function getPressroom(): ?Pressroom
{
return $this->pressroom;
}
public function setPressroom(?Pressroom $pressroom): self
{
$this->pressroom = $pressroom;
return $this;
}
/**
* @return Collection|MotsCles[]
*/
public function getMotsCles(): Collection
{
return $this->motsCles;
}
public function addMotsCle(MotsCles $motsCle): self
{
if (!$this->motsCles->contains($motsCle)) {
$this->motsCles[] = $motsCle;
$motsCle->addClient($this);
}
return $this;
}
public function removeMotsCle(MotsCles $motsCle): self
{
if ($this->motsCles->removeElement($motsCle)) {
$motsCle->removeClient($this);
}
return $this;
}
/**
* @return Collection|Document[]
*/
public function getDocuments(): Collection
{
return $this->documents;
}
public function getDateEntree()
{
return $this->dateEntree;
}
public function addDocument(Documents $document): self
{
if (!$this->documents->contains($document)) {
$this->documents[] = $document;
$document->setClient($this);
}
return $this;
}
public function setDateEntree($dateEntree): void
{
$this->dateEntree = $dateEntree;
}
public function removeDocument(Documents $document): self
{
if ($this->documents->contains($document)) {
$this->documents->removeElement($document);
// set the owning side to null (unless already changed)
if ($document->getClient() === $this) {
$document->setClient(null);
}
} return $this;
}
public function getDateSortie()
{
return $this->dateSortie;
}
public function setDateSortie($dateSortie): void
{
$this->dateSortie = $dateSortie;
}
public function getDuree()
{
return $this->duree;
}
public function setDuree($duree): void
{
$this->duree = $duree;
}
public function getScore()
{
return $this->score;
}
public function setScore($score): void
{
$this->score = $score;
}
public function getOrganisation(): ?Organisation
{
return $this->organisation;
}
public function setOrganisation(?Organisation $organisation): self
{
$this->organisation = $organisation;
// set (or unset) the owning side of the relation if necessary
$newClient = null === $organisation ? null : $this;
if ($organisation->getClient() !== $newClient) {
$organisation->setClient($newClient);
}
return $this;
}
/**
* @return Collection|CalendrierRedactionnel[]
*/
public function getCalendrierRedactionnels(): Collection
{
return $this->calendrierRedactionnels;
}
public function addCalendrierRedactionnel(CalendrierRedactionnel $calendrierRedactionnel): self
{
if (!$this->calendrierRedactionnels->contains($calendrierRedactionnel)) {
$this->calendrierRedactionnels[] = $calendrierRedactionnel;
$calendrierRedactionnel->addClient($this);
}
return $this;
}
public function removeCalendrierRedactionnel(CalendrierRedactionnel $calendrierRedactionnel): self
{
if ($this->calendrierRedactionnels->removeElement($calendrierRedactionnel)) {
$calendrierRedactionnel->removeClient($this);
}
return $this;
}
public function getEtat(): ?Etat
{
return $this->etat;
}
public function setEtat(?Etat $etat): self
{
$this->etat = $etat;
return $this;
}
/**
* @return Collection|Membre[]
*/
public function getMembres(): Collection
{
return $this->membres;
}
public function removeMembre(Membre $membre): self
{
if ($this->membres->contains($membre)) {
$this->membres->removeElement($membre);
// set the owning side to null (unless already changed)
if ($membre->getClient() === $this) {
$membre->setClient(null);
}
} return $this;
}
}