src/Entity/BlogPostGallery.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\BlogPostGalleryRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. /**
  9.  * @ORM\Entity(repositoryClass=BlogPostGalleryRepository::class)
  10.  */
  11. class BlogPostGallery
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\Column(type="integer", nullable=true)
  21.      */
  22.     private $columns;
  23.     /**
  24.      * @ORM\Column(type="boolean", nullable=true)
  25.      */
  26.     private $hasPreview;
  27.     /**
  28.      * @ORM\OneToMany(targetEntity=BlogPostGalleryItem::class, mappedBy="gallery", orphanRemoval=true, cascade={"persist", "remove"})
  29.      * @ORM\OrderBy({"position": "ASC"})
  30.      */
  31.     private $items;
  32.     /**
  33.      * @ORM\ManyToOne(targetEntity=BlogPost::class, inversedBy="galleries")
  34.      */
  35.     private $blogPost;
  36.     /**
  37.      * @Gedmo\SortablePosition
  38.      * @ORM\Column(type="integer", nullable=true)
  39.      */
  40.     private $position;
  41.     /**
  42.      * @ORM\Column(type="string", length=255, nullable=false)
  43.      */
  44.     private $backgroundColor;
  45.     /**
  46.      * @ORM\Column(type="string", length=255, nullable=false)
  47.      */
  48.     private $titleColor;
  49.     /**
  50.      * @ORM\Column(type="string", length=255, nullable=true)
  51.      */
  52.     private $title;
  53.     /**
  54.      * @ORM\Column(type="text", nullable=true)
  55.      */
  56.     private $description;
  57.     public function __construct()
  58.     {
  59.         $this->items = new ArrayCollection();
  60.     }
  61.     public function getId(): ?int
  62.     {
  63.         return $this->id;
  64.     }
  65.     public function getColumns(): ?int
  66.     {
  67.         return $this->columns;
  68.     }
  69.     public function setColumns(?int $columns): self
  70.     {
  71.         $this->columns $columns;
  72.         return $this;
  73.     }
  74.     
  75.     public function hasPreview(): ?bool
  76.     {
  77.         return $this->hasPreview;
  78.     }
  79.     public function setHasPreview(?bool $hasPreview): self
  80.     {
  81.         $this->hasPreview $hasPreview;
  82.         return $this;
  83.     }
  84.     /**
  85.      * @return Collection<int, BlogPostGalleryItem>
  86.      */
  87.     public function getItems(): Collection
  88.     {
  89.         return $this->items;
  90.     }
  91.     public function addItem(BlogPostGalleryItem $item): self
  92.     {
  93.         if (!$this->items->contains($item)) {
  94.             $this->items[] = $item;
  95.             $item->setGallery($this);
  96.         }
  97.         return $this;
  98.     }
  99.     public function removeItem(BlogPostGalleryItem $item): self
  100.     {
  101.         if ($this->items->removeElement($item)) {
  102.             // set the owning side to null (unless already changed)
  103.             if ($item->getGallery() === $this) {
  104.                 $item->setGallery(null);
  105.             }
  106.         }
  107.         return $this;
  108.     }
  109.     public function getBlogPost(): ?BlogPost
  110.     {
  111.         return $this->blogPost;
  112.     }
  113.     public function setBlogPost(?BlogPost $blogPost): self
  114.     {
  115.         $this->blogPost $blogPost;
  116.         return $this;
  117.     }
  118.     public function getPosition(): ?int
  119.     {
  120.         return $this->position;
  121.     }
  122.     public function setPosition(?int $position): self
  123.     {
  124.         $this->position $position;
  125.         return $this;
  126.     }
  127.     public function getBackgroundColor(): string
  128.     {
  129.         return $this->backgroundColor;
  130.     }
  131.     public function setBackgroundColor(string $backgroundColor): self
  132.     {
  133.         $this->backgroundColor $backgroundColor;
  134.         return $this;
  135.     }
  136.     public function getTitleColor(): string
  137.     {
  138.         return $this->titleColor;
  139.     }
  140.     public function setTitleColor(string $titleColor): self
  141.     {
  142.         $this->titleColor $titleColor;
  143.         return $this;
  144.     }
  145.     public function getTitle(): ?string
  146.     {
  147.         return $this->title;
  148.     }
  149.     public function setTitle(?string $title): self
  150.     {
  151.         $this->title $title;
  152.         return $this;
  153.     }
  154.     public function getAdminIndexTitle(): ?string
  155.     {
  156.         $title trim((string) $this->title);
  157.         if ($title !== '') {
  158.             return $title;
  159.         }
  160.         $firstItem $this->items->first();
  161.         if ($firstItem instanceof BlogPostGalleryItem) {
  162.             return $firstItem->getAdminLabel();
  163.         }
  164.         return null;
  165.     }
  166.     public function getDescription(): ?string
  167.     {
  168.         return $this->description;
  169.     }
  170.     public function setDescription(?string $description): self
  171.     {
  172.         $this->description $description;
  173.         return $this;
  174.     }
  175. }