<?php
namespace Boab\CmsBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Boab\CmsBundle\Contract\ThumbnailInterface;
use Boab\CmsBundle\Contract\ThumbnailTrait;
/**
* Photo
*
* @ORM\Table(name="photo")
* @ORM\Entity(repositoryClass="Boab\CmsBundle\Repository\PhotoRepository")
*/
class Photo implements PhotoInterface, ThumbnailInterface
{
use ThumbnailTrait;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", precision=0, scale=0, nullable=false, unique=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $title;
/**
* @var \DateTime
*
* @ORM\Column(name="created_at", type="datetime", precision=0, scale=0, nullable=false, unique=false)
*/
private $createdAt;
/**
* @var \Invetico\AlbumBundle\Entity\Album
*
* @ORM\ManyToOne(targetEntity="Boab\CmsBundle\Entity\Content", inversedBy="photos")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="content_id", referencedColumnName="id", nullable=true)
* })
*/
private $content;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $mimeType;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
/**
* Set createdAt
*
* @param \DateTime $createdAt
* @return Photo
*/
public function setCreatedAt($createdAt)
{
$this->createdAt = $createdAt;
return $this;
}
/**
* Get createdAt
*
* @return \DateTime
*/
public function getCreatedAt()
{
return $this->createdAt->format($this->dateformat);
}
/**
* Set user
*
* @param \Invetico\UserBundle\Entity\User $user
* @return Photo
*/
public function setUser(\Boab\CmsBundle\Entity\User $user = null)
{
$this->user = $user;
return $this;
}
/**
* Get user
*
* @return \Invetico\UserBundle\Entity\User
*/
public function getUser()
{
return $this->user;
}
/**
* Set content
*
* @param \Boab\CmsBundle\Entity\Content $content
*
* @return Photo
*/
public function setContent(\Boab\CmsBundle\Entity\Content $content = null)
{
$this->content = $content;
return $this;
}
/**
* Get content
*
* @return \Boab\CmsBundle\Entity\Content
*/
public function getContent()
{
return $this->content;
}
public function getThumbnailPath(): string
{
return $this->getUploadRoot().'/'.$this->thumbnail;
}
public function getUploadRoot(): string
{
return $this->getContent()->getId();
}
public function getMimeType(): ?string
{
return $this->mimeType;
}
public function setMimeType(?string $mimeType): self
{
$this->mimeType = $mimeType;
return $this;
}
}