<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\WebMapRepository")
*/
class WebMap
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\Column(type="json", nullable=true)
*/
private $parameters;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\WebMapTemplate", inversedBy="webMaps")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="map_template_id", referencedColumnName="id")
* })
*/
private $mapTemplate;
/**
* @ORM\ManytoOne(targetEntity="App\Entity\WebMapPopupTemplate", inversedBy="webMaps")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="popup_template_id", referencedColumnName="id")
* })
*/
private $popupTemplate;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $createdAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $updatedAt;
/**
* @ORM\Column(type="integer", nullable=true, options={"default":0, "comment":"code de statut : 0=OK"})
*/
private $state;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="webMaps")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="owner_id", referencedColumnName="id")
* })
*/
private $owner;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\DnsitEntity", inversedBy="webMaps")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="entity_id", referencedColumnName="id")
* })
*/
private $entity;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Tag", inversedBy="webMaps")
*/
private $tags;
/**
* @var \Doctrine\Common\Collections\Collection
*
* @ORM\OneToMany(targetEntity="App\Entity\WebMapItem", mappedBy="webMap", cascade={"persist","remove"}, orphanRemoval=true)
* @ORM\OrderBy({"ordering" = "ASC"})
*/
private $items;
/**
* @var \Doctrine\Common\Collections\Collection
*
* @ORM\OneToMany(targetEntity="App\Entity\WebMapPopupBlock", mappedBy="webMap", cascade={"persist","remove"})
*/
private $popupBlocks;
/**
* Constructor
*/
public function __construct()
{
$this->tags = new ArrayCollection();
$this->items = new ArrayCollection();
$this->popupBlocks = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
public function getParameters(): ?array
{
return $this->parameters;
}
public function setParameters(?array $parameters): self
{
$this->parameters = $parameters;
return $this;
}
public function getMapTemplate(): ?WebMapTemplate
{
return $this->mapTemplate;
}
public function setMapTemplate(?WebMapTemplate $mapTemplate): self
{
$this->mapTemplate = $mapTemplate;
return $this;
}
public function getPopupTemplate(): ?WebMapPopupTemplate
{
return $this->popupTemplate;
}
public function setPopupTemplate(?WebMapPopupTemplate $popupTemplate): self
{
$this->popupTemplate = $popupTemplate;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(?\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getState(): ?int
{
return $this->state;
}
public function setState(?int $state): self
{
$this->state = $state;
return $this;
}
public function getOwner(): ?User
{
return $this->owner;
}
public function setOwner(?User $owner): self
{
$this->owner = $owner;
return $this;
}
public function getEntity(): ?DnsitEntity
{
return $this->entity;
}
public function setEntity(?DnsitEntity $entity): self
{
$this->entity = $entity;
return $this;
}
/**
* @return Collection|Tag[]
*/
public function getTags(): Collection
{
return $this->tags;
}
public function addTag(Tag $tag): self
{
if (!$this->tags->contains($tag)) {
$this->tags[] = $tag;
// ajouter aussi la relation correspondante de l'autre côté pour éviter les incohérences
$tag->addWebMap($this);
}
return $this;
}
public function removeTag(Tag $tag): self
{
if ($this->tags->contains($tag)) {
$this->tags->removeElement($tag);
// passer l'autre côté à null pour éviter les incohérences
if ($tag->getWebMaps() === $this) {
$tag->setWebMap(null);
}
}
return $this;
}
/**
* @return Collection|WebMapItem[]
*/
public function getItems(): Collection
{
return $this->items;
}
public function addItem(WebMapItem $item): self
{
if (!$this->items->contains($item)) {
$this->items[] = $item;
// ajouter aussi la relation correspondante de l'autre côté pour éviter les incohérences
$item->setWebMap($this);
}
return $this;
}
public function removeItem(WebMapItem $item): self
{
if ($this->items->contains($item)) {
$this->items->removeElement($item);
// passer l'autre côté à null pour éviter les incohérences
if ($item->getWebMap() === $this) {
$item->setWebMap(null);
}
}
return $this;
}
/**
* @return Collection|WebMapPopupBlocks[]
*/
public function getPopupBlocks(): Collection
{
return $this->popupBlocks;
}
public function addPopupBlock(WebMapPopupBlock $popupBlock): self
{
if (!$this->popupBlocks->contains($popupBlock)) {
$this->popupBlocks[] = $popupBlock;
// ajouter aussi la relation correspondante de l'autre côté pour éviter les incohérences
$popupBlock->setWebMap($this);
}
return $this;
}
public function removePopupBlock(WebMapPopupBlock $popupBlock): self
{
if ($this->popupBlocks->contains($popupBlock)) {
$this->popupBlocks->removeElement($popupBlock);
// passer l'autre côté à null pour éviter les incohérences
if ($popupBlock->getWebMap() === $this) {
$popupBlock->setWebMap(null);
}
}
return $this;
}
}