src/Entity/Gallery.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use App\Entity\Traits\ActiveTrait;
  5. use App\Entity\Traits\DeleteTrait;
  6. use App\Entity\Traits\TranslateTrait;
  7. use App\Repository\GalleryRepository;
  8. use Gedmo\Mapping\Annotation as Gedmo;
  9. use App\Entity\Interfaces\DefaultEntity;
  10. use App\Entity\Traits\TitleAndContentTrait;
  11. use Doctrine\Common\Collections\Collection;
  12. use Doctrine\Common\Collections\ArrayCollection;
  13. use Gedmo\Timestampable\Traits\TimestampableEntity;
  14. /**
  15.  * @Gedmo\Loggable
  16.  */
  17. #[ORM\Entity(repositoryClassGalleryRepository::class)]
  18. class Gallery implements DefaultEntity
  19. {
  20.     use TitleAndContentTrait;
  21.     use ActiveTrait;
  22.     use DeleteTrait;
  23.     use TimestampableEntity;
  24.     use TranslateTrait;
  25.     #[ORM\Id]
  26.     #[ORM\GeneratedValue]
  27.     #[ORM\Column(type:"integer")]
  28.     private $id;
  29.     #[ORM\OneToMany(mappedBy'gallery'targetEntityGalleryImage::class, orphanRemovaltrue)]
  30.     private $galleryImages;
  31.     public function __construct()
  32.     {
  33.         $this->galleryImages = new ArrayCollection();
  34.     }
  35.     public function getId(): ?int
  36.     {
  37.         return $this->id;
  38.     }
  39.     /**
  40.      * @return Collection<int, GalleryImage>
  41.      */
  42.     public function getGalleryImages(): Collection
  43.     {
  44.         return $this->galleryImages;
  45.     }
  46.     public function addGalleryImage(GalleryImage $galleryImage): self
  47.     {
  48.         if (!$this->galleryImages->contains($galleryImage)) {
  49.             $this->galleryImages[] = $galleryImage;
  50.             $galleryImage->setGallery($this);
  51.         }
  52.         return $this;
  53.     }
  54.     public function removeGalleryImage(GalleryImage $galleryImage): self
  55.     {
  56.         if ($this->galleryImages->removeElement($galleryImage)) {
  57.             // set the owning side to null (unless already changed)
  58.             if ($galleryImage->getGallery() === $this) {
  59.                 $galleryImage->setGallery(null);
  60.             }
  61.         }
  62.         return $this;
  63.     }
  64. }