<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Sonata\MediaBundle\Entity\BaseGallery;
class Gallery {
/**
* @var integer
*/
private $id;
/**
* @var integer
*/
private $ownerID;
/**
* @var string
*/
private $context;
/**
* @var string
*/
private $name;
/**
* @var boolean
*/
private $enabled;
/**
* @var \DateTime
*/
private $updatedAt;
/**
* @var \DateTime
*/
private $createdAt;
/**
* @var string
*/
private $defaultFormat = 'reference';
/**
* @var \Doctrine\Common\Collections\Collection
*/
private $galleryItems;
public function __construct() {
$this->galleryItems = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Get id
*
* @return integer
*/
public function getId() {
return $this->id;
}
/**
* Set ownerID
*
* @param integer $ownerID
*
* @return Gallery
*/
public function setOwnerID($ownerID) {
$this->ownerID = $ownerID;
return $this;
}
/**
* Get ownerID
*
* @return integer
*/
public function getOwnerID() {
return $this->ownerID;
}
public function setName($name) {
$this->name = $name;
}
public function getName() {
return $this->name;
}
public function setContext($context) {
$this->context = $context;
}
public function getContext() {
return $this->context;
}
public function setEnabled($enabled) {
$this->enabled = $enabled;
}
public function getEnabled() {
return $this->enabled;
}
public function setUpdatedAt($updatedAt) {
$this->updatedAt = $updatedAt;
}
public function getUpdatedAt() {
return $this->updatedAt;
}
public function setCreatedAt($createdAt) {
$this->createdAt = $createdAt;
}
public function getCreatedAt() {
return $this->createdAt;
}
public function setDefaultFormat($defaultFormat) {
$this->defaultFormat = $defaultFormat;
}
public function getDefaultFormat() {
return $this->defaultFormat;
}
public function setGalleryItems($galleryItems) {
$this->galleryItems->clear();
foreach ($galleryItems as $galleryItem) {
$this->addGalleryItem($galleryItem);
}
}
public function getGalleryItems() {
return $this->galleryItems;
}
public function addGalleryItem($galleryItem) {
$galleryItem->setGallery($this);
$this->galleryItems[] = $galleryItem;
}
public function removeGalleryItem($galleryItem) {
if ($this->galleryItems->contains($galleryItem)) {
$this->galleryItems->removeElement($galleryItem);
}
}
public function reorderGalleryItems() {
$iterator = $this->getGalleryItems()->getIterator();
if (!$iterator instanceof \ArrayIterator) {
throw new \RuntimeException(sprintf(
'The gallery %s cannot be reordered, $galleryItems should implement %s',
$this->getId() ?? '',
\ArrayIterator::class
));
}
$iterator->uasort(static function ($a, $b): int {
return $a->getPosition() <=> $b->getPosition();
});
$this->setGalleryItems($iterator);
}
/**
* @var \App\Entity\MediaGalleryCategory
*/
private $mediaGalleryCategory;
/**
* Set mediaGalleryCategory.
*
* @param \App\Entity\MediaGalleryCategory|null $mediaGalleryCategory
*
* @return Gallery
*/
public function setMediaGalleryCategory(\App\Entity\MediaGalleryCategory $mediaGalleryCategory = null) {
$this->mediaGalleryCategory = $mediaGalleryCategory;
return $this;
}
/**
* Get mediaGalleryCategory.
*
* @return \App\Entity\MediaGalleryCategory|null
*/
public function getMediaGalleryCategory() {
return $this->mediaGalleryCategory;
}
public function __toString() {
return $this->getName() ?? '-';
}
}