<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
// use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Serializer\Annotation\Groups;
use App\Entity\BasePost;
/**
* @ORM\Entity(repositoryClass="App\Repository\StructureRepository")
* @UniqueEntity("name")
*/
class Structure
{
use BasePost;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"searchable"})
*/
private $subtitle;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $address;
/**
* @ORM\Column(type="integer", nullable=true)
* @Groups({"searchable"})
*/
private $postalCode;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"searchable"})
*/
private $town;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $phone;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Assert\Email
*/
private $email;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Assert\Url
*/
private $website;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $longitude;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $latitude;
/* relations */
// /**
// * @ORM\ManyToMany(targetEntity="App\Entity\Article", inversedBy="structures")
// */
// private $articles;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Media", mappedBy="structures", cascade={"persist", "remove"})
*/
private $medias;
/**
* @see BasePost
* @ORM\ManyToMany(targetEntity="App\Entity\Tag", inversedBy="structures")
*/
private $tags;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Event", inversedBy="eventHosters")
* @ORM\JoinTable(name="structure_event_hosted",
* joinColumns={@ORM\JoinColumn(name="structure_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="event_id", referencedColumnName="id")}
* )
*/
private $hostedEvents;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Event", inversedBy="eventPartners")
* @ORM\JoinTable(name="structure_event_partnering",
* joinColumns={@ORM\JoinColumn(name="structure_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="event_id", referencedColumnName="id")}
* )
*/
private $partneringEvents;
/* self referencing */
/**
* @ORM\OneToMany(targetEntity="App\Entity\Structure", mappedBy="host")
* @ORM\OrderBy({"name" = "ASC"})
*/
private $hosteds;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Structure", inversedBy="hosteds")
* @ORM\JoinTable(name="structure_structure_host",
* joinColumns={@ORM\JoinColumn(name="structure_source", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="structure_target", referencedColumnName="id")}
* )
*/
private $host;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Structure", mappedBy="includer")
* @ORM\OrderBy({"name" = "ASC"})
*/
private $includeds;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Structure", inversedBy="includeds")
* @ORM\JoinTable(name="structure_structure_includer",
* joinColumns={@ORM\JoinColumn(name="structure_source", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="structure_target", referencedColumnName="id")}
* )
*/
private $includer;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Structure")
* @ORM\OrderBy({"name" = "ASC"})
* @ORM\JoinTable(name="structure_structure_partner",
* joinColumns={@ORM\JoinColumn(name="structure_source", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="structure_target", referencedColumnName="id")}
* )
*/
private $partners;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\QuestionAnswer")
* @ORM\OrderBy({"priority" = "DESC", "name" = "ASC"})
*/
private $seealsoQuestionAnswers;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Structure")
* @ORM\OrderBy({"priority" = "DESC", "name" = "ASC"})
* @ORM\JoinTable(name="structure_structure_seealso",
* joinColumns={@ORM\JoinColumn(name="seealso_structure_source", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="seealso_structure_target", referencedColumnName="id")}
* )
*/
private $seealsoStructures;
public function __construct()
{
$this->medias = new ArrayCollection();
$this->hostedEvents = new ArrayCollection();
$this->partneringEvents = new ArrayCollection();
$this->hosteds = new ArrayCollection();
$this->includeds = new ArrayCollection();
$this->partners = new ArrayCollection();
$this->seealsoQuestionAnswers = new ArrayCollection();
$this->seealsoStructures = new ArrayCollection();
}
public function __toString()
{
return $this->name;
}
public function getId(): ?int
{
return $this->id;
}
public function getSubtitle(): ?string
{
return $this->subtitle;
}
public function setSubtitle(string $subtitle): self
{
$this->subtitle = $subtitle;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(?string $address): self
{
$this->address = $address;
return $this;
}
public function getPostalCode(): ?int
{
return $this->postalCode;
}
public function setPostalCode(?int $postalCode): self
{
$this->postalCode = $postalCode;
return $this;
}
public function getTown(): ?string
{
return $this->town;
}
public function setTown(?string $town): self
{
$this->town = $town;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(?string $phone): self
{
$this->phone = $phone;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
public function getWebsite(): ?string
{
return $this->website;
}
public function setWebsite(?string $website): self
{
$this->website = $website;
return $this;
}
public function getLongitude(): ?float
{
return $this->longitude;
}
public function setLongitude(?float $longitude): self
{
$this->longitude = $longitude;
return $this;
}
public function getLatitude(): ?float
{
return $this->latitude;
}
public function setLatitude(?float $latitude): self
{
$this->latitude = $latitude;
return $this;
}
/**
* @return Collection|Media[]
*/
public function getMedias(): Collection
{
return $this->medias;
}
public function addMedia(Media $media): self
{
if (!$this->medias->contains($media)) {
$this->medias[] = $media;
$media->addStructure($this);
}
return $this;
}
public function removeMedia(Media $media): self
{
if ($this->medias->contains($media)) {
$this->medias->removeElement($media);
$media->removeStructure($this);
}
return $this;
}
/**
* @return Collection|Event[]
*/
public function getHostedEvents(): Collection
{
return $this->hostedEvents;
}
public function addHostedEvent(Event $hostedEvent): self
{
if (!$this->hostedEvents->contains($hostedEvent)) {
$this->hostedEvents[] = $hostedEvent;
$hostedEvent->addEventHoster($this);
}
return $this;
}
public function removeHostedEvent(Event $hostedEvent): self
{
if ($this->hostedEvents->contains($hostedEvent)) {
$this->hostedEvents->removeElement($hostedEvent);
$hostedEvent->removeEventHoster($this);
}
return $this;
}
/**
* @return Collection|Event[]
*/
public function getPartneringEvents(): Collection
{
return $this->partneringEvents;
}
public function addPartneringEvent(Event $partneringEvent): self
{
if (!$this->partneringEvents->contains($partneringEvent)) {
$this->partneringEvents[] = $partneringEvent;
$partneringEvent->addEventPartner($this);
}
return $this;
}
public function removePartneringEvent(Event $partneringEvent): self
{
if ($this->partneringEvents->contains($partneringEvent)) {
$this->partneringEvents->removeElement($partneringEvent);
$partneringEvent->removeEventPartner($this);
}
return $this;
}
/**
* @return Collection|Structure[]
*/
public function getHosteds(): Collection
{
return $this->hosteds;
}
public function addHosted(Structure $hosted): self
{
if (!$this->hosteds->contains($hosted)) {
$this->hosteds[] = $hosted;
$hosted->setHost($this);
}
return $this;
}
public function removeHosted(Structure $hosted): self
{
if ($this->hosteds->contains($hosted)) {
$this->hosteds->removeElement($hosted);
// set the owning side to null (unless already changed)
if ($hosted->getHost() === $this) {
$hosted->setHost(null);
}
}
return $this;
}
public function getHost(): ?self
{
return $this->host;
}
public function setHost(?self $host): self
{
$this->host = $host;
return $this;
}
/**
* @return Collection|Structure[]
*/
public function getIncludeds(): Collection
{
return $this->includeds;
}
public function addIncluded(Structure $included): self
{
if (!$this->includeds->contains($included)) {
$this->includeds[] = $included;
$included->setIncluder($this);
}
return $this;
}
public function removeIncluded(Structure $included): self
{
if ($this->includeds->contains($included)) {
$this->includeds->removeElement($included);
// set the owning side to null (unless already changed)
if ($included->getIncluder() === $this) {
$included->setIncluder(null);
}
}
return $this;
}
public function getIncluder(): ?self
{
return $this->includer;
}
public function setIncluder(?self $includer): self
{
$this->includer = $includer;
return $this;
}
/**
* @return Collection|Structure[]
*/
public function getPartners(): Collection
{
return $this->partners;
}
public function addPartner(Structure $partner): self
{
if (!$this->partners->contains($partner)) {
$this->partners[] = $partner;
$partner->addPartner($this); // explicitly bidirectionnal
}
return $this;
}
public function removePartner(Structure $partner): self
{
if ($this->partners->contains($partner)) {
$this->partners->removeElement($partner);
$partner->removePartner($this); // explicitly bidirectionnal
}
return $this;
}
/**
* @return Collection|QuestionAnswer[]
*/
public function getSeealsoQuestionAnswers(): Collection
{
return $this->seealsoQuestionAnswers;
}
public function addSeealsoQuestionAnswer(QuestionAnswer $questionAnswer): self
{
if (!$this->seealsoQuestionAnswers->contains($questionAnswer)) {
$this->seealsoQuestionAnswers[] = $questionAnswer;
$questionAnswer->addSeealsoQuestionAnswer($this);
}
return $this;
}
public function removeSeealsoQuestionAnswer(QuestionAnswer $questionAnswer): self
{
if ($this->seealsoQuestionAnswers->contains($questionAnswer)) {
$this->seealsoQuestionAnswers->removeElement($questionAnswer);
$questionAnswer->removeSeealsoQuestionAnswer($this);
}
return $this;
}
/**
* @return Collection|Structure[]
*/
public function getSeealsoStructures(): Collection
{
return $this->seealsoStructures;
}
public function addSeealsoStructure(Structure $structure): self
{
if (!$this->seealsoStructures->contains($structure)) {
$this->seealsoStructures[] = $structure;
$structure->addSeealsoStructure($this);
}
return $this;
}
public function removeSeealsoStructure(Structure $structure): self
{
if ($this->seealsoStructures->contains($structure)) {
$this->seealsoStructures->removeElement($structure);
$structure->removeSeealsoStructure($this);
}
return $this;
}
}