src/Entity/WebMapTemplate.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\WebMapTemplateRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=WebMapTemplateRepository::class)
  9.  */
  10. class WebMapTemplate
  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)
  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\OneToMany(targetEntity=WebMap::class, mappedBy="mapTemplate")
  36.      */
  37.     private $webMaps;
  38.     public function __construct()
  39.     {
  40.         $this->webMaps = new ArrayCollection();
  41.     }
  42.     public function getId(): ?int
  43.     {
  44.         return $this->id;
  45.     }
  46.     public function getName(): ?string
  47.     {
  48.         return $this->name;
  49.     }
  50.     public function setName(string $name): self
  51.     {
  52.         $this->name $name;
  53.         return $this;
  54.     }
  55.     public function getGabaritName(): ?string
  56.     {
  57.         return $this->gabaritName;
  58.     }
  59.     public function setGabaritName(?string $gabaritName): self
  60.     {
  61.         $this->gabaritName $gabaritName;
  62.         return $this;
  63.     }
  64.     public function getThumbnail(): ?string
  65.     {
  66.         return $this->thumbnail;
  67.     }
  68.     public function setThumbnail(?string $thumbnail): self
  69.     {
  70.         $this->thumbnail $thumbnail;
  71.         return $this;
  72.     }
  73.     public function getPreview(): ?string
  74.     {
  75.         return $this->preview;
  76.     }
  77.     public function setPreview(?string $preview): self
  78.     {
  79.         $this->preview $preview;
  80.         return $this;
  81.     }
  82.     /**
  83.      * @return Collection|WebMap[]
  84.      */
  85.     public function getWebMaps(): Collection
  86.     {
  87.         return $this->webMaps;
  88.     }
  89.     public function addWebMap(WebMap $webMap): self
  90.     {
  91.         if (!$this->webMaps->contains($webMap)) {
  92.             $this->webMaps[] = $webMap;
  93.             // ajouter aussi la relation correspondante de l'autre côté pour éviter les incohérences
  94.             $webMap->setMapTemplate($this);
  95.         }
  96.         return $this;
  97.     }
  98.     public function removeWebMap(WebMap $webMap): self
  99.     {
  100.         if ($this->webMaps->contains($webMap)) {
  101.             $this->webMaps->removeElement($webMap);
  102.             // passer l'autre côté à null pour éviter les incohérences
  103.             if ($webMap->getMapTemplate() === $this) {
  104.                 $webMap->setMapTemplate(null);
  105.             }
  106.         }
  107.         return $this;
  108.     }
  109. }