src/Entity/Structure.php line 20

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 Gedmo\Mapping\Annotation as Gedmo;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. use App\Entity\BasePost;
  11. /**
  12.  * @ORM\Entity(repositoryClass="App\Repository\StructureRepository")
  13.  * @UniqueEntity("name")
  14.  */
  15. class Structure
  16. {
  17.     use BasePost;
  18.     /**
  19.      * @ORM\Column(type="string", length=255, nullable=true)
  20.      * @Groups({"searchable"})
  21.      */
  22.     private $subtitle;
  23.     /**
  24.      * @ORM\Column(type="text", nullable=true)
  25.      */
  26.     private $address;
  27.     /**
  28.      * @ORM\Column(type="integer", nullable=true)
  29.      * @Groups({"searchable"})
  30.      */
  31.     private $postalCode;
  32.     /**
  33.      * @ORM\Column(type="string", length=255, nullable=true)
  34.      * @Groups({"searchable"})
  35.      */
  36.     private $town;
  37.     /**
  38.      * @ORM\Column(type="string", length=255, nullable=true)
  39.      */
  40.     private $phone;
  41.     /**
  42.      * @ORM\Column(type="string", length=255, nullable=true)
  43.      * @Assert\Email
  44.      */
  45.     private $email
  46.     /**
  47.      * @ORM\Column(type="string", length=255, nullable=true)
  48.      * @Assert\Url
  49.      */
  50.     private $website;
  51.     /**
  52.      * @ORM\Column(type="float", nullable=true)
  53.      */
  54.     private $longitude;
  55.     /**
  56.      * @ORM\Column(type="float", nullable=true)
  57.      */
  58.     private $latitude;
  59.     /* relations */
  60.     // /**
  61.     //  * @ORM\ManyToMany(targetEntity="App\Entity\Article", inversedBy="structures")
  62.     //  */
  63.     // private $articles;
  64.     /**
  65.      * @ORM\ManyToMany(targetEntity="App\Entity\Media", mappedBy="structures", cascade={"persist", "remove"})
  66.      */
  67.     private $medias;
  68.         
  69.     /**
  70.      * @see BasePost
  71.      * @ORM\ManyToMany(targetEntity="App\Entity\Tag", inversedBy="structures")
  72.      */
  73.     private $tags;
  74.         
  75.     /**
  76.      * @ORM\ManyToMany(targetEntity="App\Entity\Event", inversedBy="eventHosters")
  77.      * @ORM\JoinTable(name="structure_event_hosted",
  78.      *      joinColumns={@ORM\JoinColumn(name="structure_id", referencedColumnName="id")},
  79.      *      inverseJoinColumns={@ORM\JoinColumn(name="event_id", referencedColumnName="id")}
  80.      * )
  81.      */
  82.     private $hostedEvents;
  83.         
  84.     /**
  85.      * @ORM\ManyToMany(targetEntity="App\Entity\Event", inversedBy="eventPartners")
  86.      * @ORM\JoinTable(name="structure_event_partnering",
  87.      *      joinColumns={@ORM\JoinColumn(name="structure_id", referencedColumnName="id")},
  88.      *      inverseJoinColumns={@ORM\JoinColumn(name="event_id", referencedColumnName="id")}
  89.      * )
  90.      */
  91.     private $partneringEvents;
  92.     
  93.     /* self referencing */
  94.     /**
  95.      * @ORM\OneToMany(targetEntity="App\Entity\Structure", mappedBy="host")
  96.      * @ORM\OrderBy({"name" = "ASC"})
  97.      */
  98.     private $hosteds;
  99.     /**
  100.      * @ORM\ManyToOne(targetEntity="App\Entity\Structure", inversedBy="hosteds")
  101.      * @ORM\JoinTable(name="structure_structure_host",
  102.      *      joinColumns={@ORM\JoinColumn(name="structure_source", referencedColumnName="id")},
  103.      *      inverseJoinColumns={@ORM\JoinColumn(name="structure_target", referencedColumnName="id")}
  104.      * )
  105.      */
  106.     private $host;
  107.     /**
  108.      * @ORM\OneToMany(targetEntity="App\Entity\Structure", mappedBy="includer")
  109.      * @ORM\OrderBy({"name" = "ASC"})
  110.      */
  111.     private $includeds;
  112.     /**
  113.      * @ORM\ManyToOne(targetEntity="App\Entity\Structure", inversedBy="includeds")
  114.      * @ORM\JoinTable(name="structure_structure_includer",
  115.      *      joinColumns={@ORM\JoinColumn(name="structure_source", referencedColumnName="id")},
  116.      *      inverseJoinColumns={@ORM\JoinColumn(name="structure_target", referencedColumnName="id")}
  117.      * )
  118.      */
  119.     private $includer;
  120.     /**
  121.      * @ORM\ManyToMany(targetEntity="App\Entity\Structure")
  122.      * @ORM\OrderBy({"name" = "ASC"})
  123.      * @ORM\JoinTable(name="structure_structure_partner",
  124.      *      joinColumns={@ORM\JoinColumn(name="structure_source", referencedColumnName="id")},
  125.      *      inverseJoinColumns={@ORM\JoinColumn(name="structure_target", referencedColumnName="id")}
  126.      * )
  127.      */
  128.     private $partners;
  129.     /**
  130.      * @ORM\ManyToMany(targetEntity="App\Entity\QuestionAnswer")
  131.      * @ORM\OrderBy({"priority" = "DESC", "name" = "ASC"})
  132.      */
  133.     private $seealsoQuestionAnswers;
  134.     /**
  135.      * @ORM\ManyToMany(targetEntity="App\Entity\Structure")
  136.      * @ORM\OrderBy({"priority" = "DESC", "name" = "ASC"})
  137.      * @ORM\JoinTable(name="structure_structure_seealso",
  138.      *      joinColumns={@ORM\JoinColumn(name="seealso_structure_source", referencedColumnName="id")},
  139.      *      inverseJoinColumns={@ORM\JoinColumn(name="seealso_structure_target", referencedColumnName="id")}
  140.      * )
  141.      */
  142.     private $seealsoStructures;
  143.     public function __construct()
  144.     {
  145.         $this->medias = new ArrayCollection();
  146.         $this->hostedEvents = new ArrayCollection();
  147.         $this->partneringEvents = new ArrayCollection();
  148.         $this->hosteds = new ArrayCollection();
  149.         $this->includeds = new ArrayCollection();
  150.         $this->partners = new ArrayCollection();
  151.         $this->seealsoQuestionAnswers = new ArrayCollection();
  152.         $this->seealsoStructures = new ArrayCollection();
  153.     }
  154.     
  155.     public function __toString()
  156.     {
  157.         return $this->name;    
  158.     }
  159.     public function getId(): ?int
  160.     {
  161.         return $this->id;
  162.     }
  163.     public function getSubtitle(): ?string
  164.     {
  165.         return $this->subtitle;
  166.     }
  167.     public function setSubtitle(string $subtitle): self
  168.     {
  169.         $this->subtitle $subtitle;
  170.         return $this;
  171.     }
  172.     public function getAddress(): ?string
  173.     {
  174.         return $this->address;
  175.     }
  176.     public function setAddress(?string $address): self
  177.     {
  178.         $this->address $address;
  179.         return $this;
  180.     }
  181.     public function getPostalCode(): ?int
  182.     {
  183.         return $this->postalCode;
  184.     }
  185.     public function setPostalCode(?int $postalCode): self
  186.     {
  187.         $this->postalCode $postalCode;
  188.         return $this;
  189.     }
  190.     public function getTown(): ?string
  191.     {
  192.         return $this->town;
  193.     }
  194.     public function setTown(?string $town): self
  195.     {
  196.         $this->town $town;
  197.         return $this;
  198.     }
  199.     public function getPhone(): ?string
  200.     {
  201.         return $this->phone;
  202.     }
  203.     public function setPhone(?string $phone): self
  204.     {
  205.         $this->phone $phone;
  206.         return $this;
  207.     }
  208.     public function getEmail(): ?string
  209.     {
  210.         return $this->email;
  211.     }
  212.     public function setEmail(?string $email): self
  213.     {
  214.         $this->email $email;
  215.         return $this;
  216.     }
  217.     public function getWebsite(): ?string
  218.     {
  219.         return $this->website;
  220.     }
  221.     public function setWebsite(?string $website): self
  222.     {
  223.         $this->website $website;
  224.         return $this;
  225.     }
  226.     public function getLongitude(): ?float
  227.     {
  228.         return $this->longitude;
  229.     }
  230.     public function setLongitude(?float $longitude): self
  231.     {
  232.         $this->longitude $longitude;
  233.         return $this;
  234.     }
  235.     public function getLatitude(): ?float
  236.     {
  237.         return $this->latitude;
  238.     }
  239.     public function setLatitude(?float $latitude): self
  240.     {
  241.         $this->latitude $latitude;
  242.         return $this;
  243.     }
  244.     /**
  245.      * @return Collection|Media[]
  246.      */
  247.     public function getMedias(): Collection
  248.     {
  249.         return $this->medias;
  250.     }
  251.     public function addMedia(Media $media): self
  252.     {
  253.         if (!$this->medias->contains($media)) {
  254.             $this->medias[] = $media;
  255.             $media->addStructure($this);
  256.         }
  257.         return $this;
  258.     }
  259.     public function removeMedia(Media $media): self
  260.     {
  261.         if ($this->medias->contains($media)) {
  262.             $this->medias->removeElement($media);
  263.             $media->removeStructure($this);
  264.         }
  265.         return $this;
  266.     }
  267.     /**
  268.      * @return Collection|Event[]
  269.      */
  270.     public function getHostedEvents(): Collection
  271.     {
  272.         return $this->hostedEvents;
  273.     }
  274.     public function addHostedEvent(Event $hostedEvent): self
  275.     {
  276.         if (!$this->hostedEvents->contains($hostedEvent)) {
  277.             $this->hostedEvents[] = $hostedEvent;
  278.             $hostedEvent->addEventHoster($this);
  279.         }
  280.         return $this;
  281.     }
  282.     public function removeHostedEvent(Event $hostedEvent): self
  283.     {
  284.         if ($this->hostedEvents->contains($hostedEvent)) {
  285.             $this->hostedEvents->removeElement($hostedEvent);
  286.             $hostedEvent->removeEventHoster($this);
  287.         }
  288.         return $this;
  289.     }
  290.     /**
  291.      * @return Collection|Event[]
  292.      */
  293.     public function getPartneringEvents(): Collection
  294.     {
  295.         return $this->partneringEvents;
  296.     }
  297.     public function addPartneringEvent(Event $partneringEvent): self
  298.     {
  299.         if (!$this->partneringEvents->contains($partneringEvent)) {
  300.             $this->partneringEvents[] = $partneringEvent;
  301.             $partneringEvent->addEventPartner($this);
  302.         }
  303.         return $this;
  304.     }
  305.     public function removePartneringEvent(Event $partneringEvent): self
  306.     {
  307.         if ($this->partneringEvents->contains($partneringEvent)) {
  308.             $this->partneringEvents->removeElement($partneringEvent);
  309.             $partneringEvent->removeEventPartner($this);
  310.         }
  311.         return $this;
  312.     }
  313.     /**
  314.      * @return Collection|Structure[]
  315.      */
  316.     public function getHosteds(): Collection
  317.     {
  318.         return $this->hosteds;
  319.     }
  320.     public function addHosted(Structure $hosted): self
  321.     {
  322.         if (!$this->hosteds->contains($hosted)) {
  323.             $this->hosteds[] = $hosted;
  324.             $hosted->setHost($this);
  325.         }
  326.         return $this;
  327.     }
  328.     public function removeHosted(Structure $hosted): self
  329.     {
  330.         if ($this->hosteds->contains($hosted)) {
  331.             $this->hosteds->removeElement($hosted);
  332.             // set the owning side to null (unless already changed)
  333.             if ($hosted->getHost() === $this) {
  334.                 $hosted->setHost(null);
  335.             }
  336.         }
  337.         return $this;
  338.     }
  339.     public function getHost(): ?self
  340.     {
  341.         return $this->host;
  342.     }
  343.     public function setHost(?self $host): self
  344.     {
  345.         $this->host $host;
  346.         return $this;
  347.     }
  348.     /**
  349.      * @return Collection|Structure[]
  350.      */
  351.     public function getIncludeds(): Collection
  352.     {
  353.         return $this->includeds;
  354.     }
  355.     public function addIncluded(Structure $included): self
  356.     {
  357.         if (!$this->includeds->contains($included)) {
  358.             $this->includeds[] = $included;
  359.             $included->setIncluder($this);
  360.         }
  361.         return $this;
  362.     }
  363.     public function removeIncluded(Structure $included): self
  364.     {
  365.         if ($this->includeds->contains($included)) {
  366.             $this->includeds->removeElement($included);
  367.             // set the owning side to null (unless already changed)
  368.             if ($included->getIncluder() === $this) {
  369.                 $included->setIncluder(null);
  370.             }
  371.         }
  372.         return $this;
  373.     }
  374.     public function getIncluder(): ?self
  375.     {
  376.         return $this->includer;
  377.     }
  378.     public function setIncluder(?self $includer): self
  379.     {
  380.         $this->includer $includer;
  381.         return $this;
  382.     }
  383.     /**
  384.      * @return Collection|Structure[]
  385.      */
  386.     public function getPartners(): Collection
  387.     {
  388.         return $this->partners;
  389.     }
  390.     public function addPartner(Structure $partner): self
  391.     {
  392.         if (!$this->partners->contains($partner)) {
  393.             $this->partners[] = $partner;
  394.             $partner->addPartner($this); // explicitly bidirectionnal
  395.         }
  396.         return $this;
  397.     }
  398.     public function removePartner(Structure $partner): self
  399.     {
  400.         if ($this->partners->contains($partner)) {
  401.             $this->partners->removeElement($partner);
  402.             $partner->removePartner($this); // explicitly bidirectionnal
  403.         }
  404.         return $this;
  405.     }
  406.     /**
  407.      * @return Collection|QuestionAnswer[]
  408.      */
  409.     public function getSeealsoQuestionAnswers(): Collection
  410.     {
  411.         return $this->seealsoQuestionAnswers;
  412.     }
  413.     public function addSeealsoQuestionAnswer(QuestionAnswer $questionAnswer): self
  414.     {
  415.         if (!$this->seealsoQuestionAnswers->contains($questionAnswer)) {
  416.             $this->seealsoQuestionAnswers[] = $questionAnswer;
  417.             $questionAnswer->addSeealsoQuestionAnswer($this);
  418.         }
  419.         return $this;
  420.     }
  421.     public function removeSeealsoQuestionAnswer(QuestionAnswer $questionAnswer): self
  422.     {
  423.         if ($this->seealsoQuestionAnswers->contains($questionAnswer)) {
  424.             $this->seealsoQuestionAnswers->removeElement($questionAnswer);
  425.             $questionAnswer->removeSeealsoQuestionAnswer($this);
  426.         }
  427.         return $this;
  428.     }
  429.     /**
  430.      * @return Collection|Structure[]
  431.      */
  432.     public function getSeealsoStructures(): Collection
  433.     {
  434.         return $this->seealsoStructures;
  435.     }
  436.     public function addSeealsoStructure(Structure $structure): self
  437.     {
  438.         if (!$this->seealsoStructures->contains($structure)) {
  439.             $this->seealsoStructures[] = $structure;
  440.             $structure->addSeealsoStructure($this);
  441.         }
  442.         return $this;
  443.     }
  444.     public function removeSeealsoStructure(Structure $structure): self
  445.     {
  446.         if ($this->seealsoStructures->contains($structure)) {
  447.             $this->seealsoStructures->removeElement($structure);
  448.             $structure->removeSeealsoStructure($this);
  449.         }
  450.         return $this;
  451.     }
  452.     
  453. }