<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\Traits\ActiveTrait;
use App\Entity\Traits\DeleteTrait;
use App\Entity\Traits\TranslateTrait;
use App\Repository\GalleryRepository;
use Gedmo\Mapping\Annotation as Gedmo;
use App\Entity\Interfaces\DefaultEntity;
use App\Entity\Traits\TitleAndContentTrait;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
use Gedmo\Timestampable\Traits\TimestampableEntity;
/**
* @Gedmo\Loggable
*/
#[ORM\Entity(repositoryClass: GalleryRepository::class)]
class Gallery implements DefaultEntity
{
use TitleAndContentTrait;
use ActiveTrait;
use DeleteTrait;
use TimestampableEntity;
use TranslateTrait;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type:"integer")]
private $id;
#[ORM\OneToMany(mappedBy: 'gallery', targetEntity: GalleryImage::class, orphanRemoval: true)]
private $galleryImages;
public function __construct()
{
$this->galleryImages = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
/**
* @return Collection<int, GalleryImage>
*/
public function getGalleryImages(): Collection
{
return $this->galleryImages;
}
public function addGalleryImage(GalleryImage $galleryImage): self
{
if (!$this->galleryImages->contains($galleryImage)) {
$this->galleryImages[] = $galleryImage;
$galleryImage->setGallery($this);
}
return $this;
}
public function removeGalleryImage(GalleryImage $galleryImage): self
{
if ($this->galleryImages->removeElement($galleryImage)) {
// set the owning side to null (unless already changed)
if ($galleryImage->getGallery() === $this) {
$galleryImage->setGallery(null);
}
}
return $this;
}
}