src/Entity/WebListItemTemplate.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\WebListItemTemplateRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity (repositoryClass=WebListItemTemplateRepository::class)
  9.  */
  10. class WebListItemTemplate
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string", length=255, unique=true)
  20.      */
  21.     private $name;
  22.     /**
  23.      * @ORM\Column(type="string", length=255, nullable=true)
  24.      */
  25.     private $gabaritName;
  26.     /**
  27.      * @ORM\Column(type="string", length=255, nullable=true)
  28.      */
  29.     private $thumbnail;
  30.     /**
  31.      * @ORM\Column(type="string", length=255, nullable=true)
  32.      */
  33.     private $preview;
  34.     /**
  35.      * @ORM\ManyToMany(targetEntity=WebListItemTemplateTag::class, inversedBy="templates", cascade={"persist"})
  36.      */
  37.     private $tags;
  38.     /**
  39.      * @ORM\OneToMany(targetEntity=WebList::class, mappedBy="listItemTemplate")
  40.      */
  41.     private $webLists;
  42.     /**
  43.      * @ORM\OneToMany(targetEntity=ListModel::class, mappedBy="listItemTemplate")
  44.      */
  45.     private $listModels;
  46.     public function __construct()
  47.     {
  48.         $this->tags = new ArrayCollection();
  49.         $this->webLists = new ArrayCollection();
  50.         $this->listModels = new ArrayCollection();
  51.     }
  52.     public function getId() : ?int
  53.     {
  54.         return $this->id;
  55.     }
  56.     public function getName() : string
  57.     {
  58.         return $this->name;
  59.     }
  60.     public function setName(string $name) : self
  61.     {
  62.         $this->name $name;
  63.         return $this;
  64.     }
  65.     public function getGabaritName() : ?string
  66.     {
  67.         return $this->gabaritName;
  68.     }
  69.     public function setGabaritName(?string $gabaritName) : self
  70.     {
  71.         $this->gabaritName $gabaritName;
  72.         return $this;
  73.     }
  74.     public function getThumbnail() : ?string
  75.     {
  76.         return $this->thumbnail;
  77.     }
  78.     public function setThumbnail(?string $thumbnail) : self
  79.     {
  80.         $this->thumbnail $thumbnail;
  81.         return $this;
  82.     }
  83.     public function getPreview() : ?string
  84.     {
  85.         return $this->preview;
  86.     }
  87.     public function setPreview(?string $preview) : self
  88.     {
  89.         $this->preview $preview;
  90.         return $this;
  91.     }
  92.     /**
  93.      * @return Collection|WebListItemTemplateTag[]
  94.      */
  95.     public function getTags() : Collection
  96.     {
  97.         return $this->tags;
  98.     }
  99.     public function addTag(WebListItemTemplateTag $tag) : self
  100.     {
  101.         if (!$this->tags->contains($tag)) {
  102.             $this->tags[] = $tag;
  103.         }
  104.         return $this;
  105.     }
  106.     public function removeTag(WebListItemTemplateTag $tag) : self
  107.     {
  108.         $this->tags->removeElement($tag);
  109.         return $this;
  110.     }
  111.     /**
  112.      * @return Collection|WebList[]
  113.      */
  114.     public function getWebLists() : Collection
  115.     {
  116.         return $this->webLists;
  117.     }
  118.     public function addWebList(WebList $webList) : self
  119.     {
  120.         if (!$this->webLists->contains($webList)) {
  121.             $this->webLists[] = $webList;
  122.             $webList->setListItemTemplate($this);
  123.         }
  124.         return $this;
  125.     }
  126.     public function removeWebList(WebList $webList) : self
  127.     {
  128.         if ($this->webLists->removeElement($webList)) {
  129.             // set the owning side to null (unless already changed)
  130.             if ($webList->getListItemTemplate() === $this) {
  131.                 $webList->setListItemTemplate(null);
  132.             }
  133.         }
  134.         return $this;
  135.     }
  136.     /**
  137.      * @return Collection|ListModel[]
  138.      */
  139.     public function getListModels() : Collection
  140.     {
  141.         return $this->listModels;
  142.     }
  143.     public function addListModel(ListModel $listModel) : self
  144.     {
  145.         if (!$this->listModels->contains($listModel)) {
  146.             $this->listModels[] = $listModel;
  147.             $listModel->setListItemTemplate($this);
  148.         }
  149.         return $this;
  150.     }
  151.     public function removeListModel(ListModel $listModel) : self
  152.     {
  153.         if ($this->listModels->removeElement($listModel)) {
  154.             // set the owning side to null (unless already changed)
  155.             if ($listModel->getListItemTemplate() === $this) {
  156.                 $listModel->setListItemTemplate(null);
  157.             }
  158.         }
  159.         return $this;
  160.     }
  161.     public function toExport() : array
  162.     {
  163.         $template = array();
  164.         $template['name'] = $this->getName();
  165.         $template['gabaritName'] = $this->getGabaritName();
  166.         $template['thumbnail'] = $this->getThumbnail();
  167.         $template['preview'] = $this->getPreview();
  168.         $template['tags'] = array();
  169.         foreach ($this->getTags() as $tag) {
  170.             $template['tags'][] = $tag->toExport();
  171.         }
  172.         return $template;
  173.     }
  174. }