<?php
namespace MLDev\GalleryBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use MLDev\BaseBundle\Entity\Traits\Timestampable;
/**
* Album
*
* @ORM\Table(name="MLDev_Gallery_Album")
* @ORM\Entity(repositoryClass="MLDev\GalleryBundle\Repository\AlbumRepository")
* @ORM\HasLifecycleCallbacks()
*/
class Album
{
use Timestampable;
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255)
*/
private $name;
/**
* @var string|null
*
* @ORM\Column(name="description", type="text", nullable=true)
*/
private $description;
/**
* @var int|null
*
* @ORM\Column(name="priority", type="integer", nullable=true)
*/
private $priority = 100;
/**
* @var bool
*
* @ORM\Column(name="isActive", type="boolean")
*/
private $isActive = true;
/**
* @ORM\ManyToOne(targetEntity="MLDev\GalleryBundle\Entity\Gallery", inversedBy="albums")
* @ORM\JoinColumn(name="galleryId", referencedColumnName="id", onDelete="CASCADE")
*/
private $gallery;
/**
* @ORM\OneToMany(targetEntity="MLDev\GalleryBundle\Entity\Item", mappedBy="album", fetch="EXTRA_LAZY", cascade={"persist"})
* @ORM\OrderBy({"priority" = "ASC", "id" = "DESC"})
*/
private $items;
/**
* Album constructor.
*/
public function __construct()
{
$this->items = new ArrayCollection();
}
/**
* Get id.
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set name.
*
* @param string $name
*
* @return Album
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name.
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set description.
*
* @param string|null $description
*
* @return Album
*/
public function setDescription($description = null)
{
$this->description = $description;
return $this;
}
/**
* Get description.
*
* @return string|null
*/
public function getDescription()
{
return $this->description;
}
/**
* Set priority.
*
* @param int|null $priority
*
* @return Album
*/
public function setPriority($priority = null)
{
$this->priority = $priority;
return $this;
}
/**
* Get priority.
*
* @return int|null
*/
public function getPriority()
{
return $this->priority;
}
/**
* Set isActive.
*
* @param bool $isActive
*
* @return Album
*/
public function setIsActive($isActive)
{
$this->isActive = $isActive;
return $this;
}
/**
* Get isActive.
*
* @return bool
*/
public function getIsActive()
{
return $this->isActive;
}
/**
* @return mixed
*/
public function getGallery()
{
return $this->gallery;
}
/**
* @param mixed $gallery
*/
public function setGallery($gallery)
{
$this->gallery = $gallery;
}
/**
* Add new item
*
* @param Item $item
*/
public function addItem(Item $item)
{
if (!$this->items->contains($item)) {
$item->setAlbum($this);
$this->items->add($item);
}
}
/**
* Remove item
*
* @param Item $item
*/
public function removeItem(Item $item)
{
if ($this->items->contains($item)) {
$this->items->removeElement($item);
}
}
/**
* @return mixed
*/
public function getItems()
{
return $this->items;
}
}