<?php
namespace MLDev\GalleryBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use MLDev\BaseBundle\Entity\Traits\Timestampable;
use Symfony\Component\HttpFoundation\File\File;
/**
* Item
*
* @ORM\Table(name="MLDev_Gallery_Item")
* @ORM\Entity(repositoryClass="MLDev\GalleryBundle\Repository\ItemRepository")
* @ORM\HasLifecycleCallbacks()
*/
class Item
{
use Timestampable;
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @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;
/**
* @var string|null
*
* @ORM\Column(name="title", type="string", length=255, nullable=true)
*/
private $title;
/**
* @var string|null
*
* @ORM\Column(name="description", type="text", nullable=true)
*/
private $description;
/**
* @var string|null
*
* @ORM\Column(name="link", type="string", length=255, nullable=true)
*/
private $link;
/**
* @ORM\ManyToOne(targetEntity="MLDev\GalleryBundle\Entity\Album", inversedBy="items", cascade={"persist"})
* @ORM\JoinColumn(name="albumId", referencedColumnName="id", onDelete="CASCADE"))
*/
private $album;
/**
* @var string
*
* @ORM\Column(name="path", type="string", length=255)
*/
protected $path;
/**
* @var string
*
* @ORM\Column(name="uri", type="string", length=255)
*/
protected $uri;
/**
* @var File|string
*/
private $file;
/**
* Get id.
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set priority.
*
* @param int|null $priority
*
* @return Item
*/
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 Item
*/
public function setIsActive($isActive)
{
$this->isActive = $isActive;
return $this;
}
/**
* Get isActive.
*
* @return bool
*/
public function getIsActive()
{
return $this->isActive;
}
/**
* Set title.
*
* @param string|null $title
*
* @return Item
*/
public function setTitle($title = null)
{
$this->title = $title;
return $this;
}
/**
* Get title.
*
* @return string|null
*/
public function getTitle()
{
return $this->title;
}
/**
* Set description.
*
* @param string|null $description
*
* @return Item
*/
public function setDescription($description = null)
{
$this->description = $description;
return $this;
}
/**
* Get description.
*
* @return string|null
*/
public function getDescription()
{
return $this->description;
}
/**
* Set link.
*
* @param string|null $link
*
* @return Item
*/
public function setLink($link = null)
{
$this->link = $link;
return $this;
}
/**
* Get link.
*
* @return string|null
*/
public function getLink()
{
return $this->link;
}
/**
* @return mixed
*/
public function getAlbum()
{
return $this->album;
}
/**
* @param $album
*/
public function setAlbum($album)
{
$this->album = $album;
}
/**
* @return mixed
*/
public function getFile()
{
if ($this->file instanceof File) {
return $this->file;
}
if (\file_exists($this->path)) {
return new File($this->path);
}
return null;
}
/**
* @param File $file
*/
public function setFile(File $file)
{
$this->file = $file;
}
/**
* @return string
*/
public function getPath()
{
return $this->path;
}
/**
* @param string $path
*/
public function setPath($path)
{
$this->path = $path;
}
/**
* @return string
*/
public function getUri()
{
return $this->uri;
}
/**
* @param string $uri
*/
public function setUri($uri)
{
$this->uri = $uri;
}
}