<?php
namespace App\Entity\Gallery;
use App\Annotation\SiteAware;
use App\Entity\AbstractBase;
use App\Entity\Interfaces\PublishedInterface;
use App\Entity\Interfaces\SiteInterface;
use App\Entity\Traits\NameTrait;
use App\Entity\Traits\PositionTrait;
use App\Entity\Traits\PublishedTrait;
use App\Entity\Traits\SiteTrait;
use App\Repository\Gallery\GalleryAlbumRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\HttpFoundation\File\UploadedFile;
/**
* @ORM\Table(name="vulco_gallery_album", indexes={@ORM\Index(name="gallery_album_site_idx", columns={"site"})})
* @ORM\Entity(repositoryClass=GalleryAlbumRepository::class)
* @Gedmo\SoftDeleteable(fieldName="removedAt", timeAware=false)
* @SiteAware(siteFieldName="site")
*/
class GalleryAlbum extends AbstractBase implements SiteInterface, PublishedInterface
{
use NameTrait;
use SiteTrait;
use PublishedTrait;
use PositionTrait;
/**
* @ORM\Column(type="string", length=255, nullable=false)
*/
private string $name;
/**
* @ORM\Column(type="integer", nullable=false)
*/
private int $position = 0;
/**
* @ORM\Column(type="text", length=10000, nullable=true)
*/
private ?string $zipLink = null;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Gallery\GalleryImage", mappedBy="album", cascade={"persist", "remove"}, orphanRemoval=true)
*/
private ?Collection $images;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Gallery\GalleryVideo", mappedBy="album", cascade={"persist", "remove"}, orphanRemoval=true)
*/
private ?Collection $videos;
/**
* @var UploadedFile[]
*/
private ?array $multipleImage = null;
public function __construct()
{
$this->images = new ArrayCollection();
$this->videos = new ArrayCollection();
$this->published = false;
}
public function getZipLink(): ?string
{
return $this->zipLink;
}
public function setZipLink(?string $zipLink): self
{
$this->zipLink = $zipLink;
return $this;
}
public function getImages(): ?Collection
{
return $this->images;
}
public function setImages(?Collection $images): self
{
$this->images = $images;
return $this;
}
public function addImage(GalleryImage $image): self
{
if (!$this->images->contains($image)) {
$this->images->add($image);
$image->setAlbum($this);
}
return $this;
}
public function removeImage(GalleryImage $image): self
{
if ($this->images->contains($image)) {
$this->images->removeElement($image);
}
return $this;
}
/**
* @return UploadedFile[]|null
*/
public function getMultipleImage(): ?array
{
return $this->multipleImage;
}
/**
* @param UploadedFile[] $multipleImage
*/
public function setMultipleImage(array $multipleImage): self
{
$this->multipleImage = $multipleImage;
return $this;
}
public function getVideos(): ?Collection
{
return $this->videos;
}
public function setVideos(?Collection $videos): self
{
$this->videos = $videos;
return $this;
}
public function addVideo(GalleryVideo $video): self
{
if (!$this->videos->contains($video)) {
$this->videos->add($video);
$video->setAlbum($this);
}
return $this;
}
public function removeVideo(GalleryVideo $video): self
{
if ($this->videos->contains($video)) {
$this->videos->removeElement($video);
}
return $this;
}
}