lib/boab/cms-bundle/src/Entity/Photo.php line 14

Open in your IDE?
  1. <?php
  2. namespace Boab\CmsBundle\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Boab\CmsBundle\Contract\ThumbnailInterface;
  5. use Boab\CmsBundle\Contract\ThumbnailTrait;
  6. /**
  7.  * Photo
  8.  *
  9.  * @ORM\Table(name="photo")
  10.  * @ORM\Entity(repositoryClass="Boab\CmsBundle\Repository\PhotoRepository")
  11.  */
  12. class Photo implements PhotoInterfaceThumbnailInterface
  13. {
  14.    use ThumbnailTrait;
  15.    
  16.     /**
  17.      * @var integer
  18.      *
  19.      * @ORM\Column(name="id", type="integer", precision=0, scale=0, nullable=false, unique=false)
  20.      * @ORM\Id
  21.      * @ORM\GeneratedValue(strategy="IDENTITY")
  22.      */
  23.     private $id;
  24.     /**
  25.      * @ORM\Column(type="string", length=255)
  26.      */
  27.     private $title;
  28.     /**
  29.      * @var \DateTime
  30.      *
  31.      * @ORM\Column(name="created_at", type="datetime", precision=0, scale=0, nullable=false, unique=false)
  32.      */
  33.     private $createdAt;
  34.     /**
  35.      * @var \Invetico\AlbumBundle\Entity\Album
  36.      *
  37.      * @ORM\ManyToOne(targetEntity="Boab\CmsBundle\Entity\Content", inversedBy="photos")
  38.      * @ORM\JoinColumns({
  39.      *   @ORM\JoinColumn(name="content_id", referencedColumnName="id", nullable=true)
  40.      * })
  41.      */
  42.     private $content;
  43.     /**
  44.      * @ORM\Column(type="string", length=100, nullable=true)
  45.      */
  46.     private $mimeType;
  47.     /**
  48.      * Get id
  49.      *
  50.      * @return integer 
  51.      */
  52.     public function getId()
  53.     {
  54.         return $this->id;
  55.     }
  56.     public function getTitle(): ?string
  57.     {
  58.         return $this->title;
  59.     }
  60.     public function setTitle(string $title): self
  61.     {
  62.         $this->title $title;
  63.         return $this;
  64.     }    
  65.     /**
  66.      * Set createdAt
  67.      *
  68.      * @param \DateTime $createdAt
  69.      * @return Photo
  70.      */
  71.     public function setCreatedAt($createdAt)
  72.     {
  73.         $this->createdAt $createdAt;
  74.         return $this;
  75.     }
  76.     /**
  77.      * Get createdAt
  78.      *
  79.      * @return \DateTime 
  80.      */
  81.     public function getCreatedAt()
  82.     {
  83.         return $this->createdAt->format($this->dateformat);
  84.     }
  85.     /**
  86.      * Set user
  87.      *
  88.      * @param \Invetico\UserBundle\Entity\User $user
  89.      * @return Photo
  90.      */
  91.     public function setUser(\Boab\CmsBundle\Entity\User $user null)
  92.     {
  93.         $this->user $user;
  94.         return $this;
  95.     }
  96.     /**
  97.      * Get user
  98.      *
  99.      * @return \Invetico\UserBundle\Entity\User 
  100.      */
  101.     public function getUser()
  102.     {
  103.         return $this->user;
  104.     }
  105.     /**
  106.      * Set content
  107.      *
  108.      * @param \Boab\CmsBundle\Entity\Content $content
  109.      *
  110.      * @return Photo
  111.      */
  112.     public function setContent(\Boab\CmsBundle\Entity\Content $content null)
  113.     {
  114.         $this->content $content;
  115.         return $this;
  116.     }
  117.     /**
  118.      * Get content
  119.      *
  120.      * @return \Boab\CmsBundle\Entity\Content
  121.      */
  122.     public function getContent()
  123.     {
  124.         return $this->content;
  125.     }    
  126.     public function getThumbnailPath(): string
  127.     {
  128.         return  $this->getUploadRoot().'/'.$this->thumbnail;
  129.     }
  130.     public function getUploadRoot(): string
  131.     {
  132.         return $this->getContent()->getId();
  133.     }
  134.     public function getMimeType(): ?string
  135.     {
  136.         return $this->mimeType;
  137.     }
  138.     public function setMimeType(?string $mimeType): self
  139.     {
  140.         $this->mimeType $mimeType;
  141.         return $this;
  142.     }
  143. }