<?php
namespace App\Entity;
use App\Repository\WebListItemTemplateRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity (repositoryClass=WebListItemTemplateRepository::class)
*/
class WebListItemTemplate
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255, unique=true)
*/
private $name;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $gabaritName;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $thumbnail;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $preview;
/**
* @ORM\ManyToMany(targetEntity=WebListItemTemplateTag::class, inversedBy="templates", cascade={"persist"})
*/
private $tags;
/**
* @ORM\OneToMany(targetEntity=WebList::class, mappedBy="listItemTemplate")
*/
private $webLists;
/**
* @ORM\OneToMany(targetEntity=ListModel::class, mappedBy="listItemTemplate")
*/
private $listModels;
public function __construct()
{
$this->tags = new ArrayCollection();
$this->webLists = new ArrayCollection();
$this->listModels = 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 getGabaritName() : ?string
{
return $this->gabaritName;
}
public function setGabaritName(?string $gabaritName) : self
{
$this->gabaritName = $gabaritName;
return $this;
}
public function getThumbnail() : ?string
{
return $this->thumbnail;
}
public function setThumbnail(?string $thumbnail) : self
{
$this->thumbnail = $thumbnail;
return $this;
}
public function getPreview() : ?string
{
return $this->preview;
}
public function setPreview(?string $preview) : self
{
$this->preview = $preview;
return $this;
}
/**
* @return Collection|WebListItemTemplateTag[]
*/
public function getTags() : Collection
{
return $this->tags;
}
public function addTag(WebListItemTemplateTag $tag) : self
{
if (!$this->tags->contains($tag)) {
$this->tags[] = $tag;
}
return $this;
}
public function removeTag(WebListItemTemplateTag $tag) : self
{
$this->tags->removeElement($tag);
return $this;
}
/**
* @return Collection|WebList[]
*/
public function getWebLists() : Collection
{
return $this->webLists;
}
public function addWebList(WebList $webList) : self
{
if (!$this->webLists->contains($webList)) {
$this->webLists[] = $webList;
$webList->setListItemTemplate($this);
}
return $this;
}
public function removeWebList(WebList $webList) : self
{
if ($this->webLists->removeElement($webList)) {
// set the owning side to null (unless already changed)
if ($webList->getListItemTemplate() === $this) {
$webList->setListItemTemplate(null);
}
}
return $this;
}
/**
* @return Collection|ListModel[]
*/
public function getListModels() : Collection
{
return $this->listModels;
}
public function addListModel(ListModel $listModel) : self
{
if (!$this->listModels->contains($listModel)) {
$this->listModels[] = $listModel;
$listModel->setListItemTemplate($this);
}
return $this;
}
public function removeListModel(ListModel $listModel) : self
{
if ($this->listModels->removeElement($listModel)) {
// set the owning side to null (unless already changed)
if ($listModel->getListItemTemplate() === $this) {
$listModel->setListItemTemplate(null);
}
}
return $this;
}
public function toExport() : array
{
$template = array();
$template['name'] = $this->getName();
$template['gabaritName'] = $this->getGabaritName();
$template['thumbnail'] = $this->getThumbnail();
$template['preview'] = $this->getPreview();
$template['tags'] = array();
foreach ($this->getTags() as $tag) {
$template['tags'][] = $tag->toExport();
}
return $template;
}
}