<?php
namespace App\Entity;
use App\Repository\ImageRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity(repositoryClass=ImageRepository::class)
* @ORM\Table(name="image_corpus", schema="bdnf", options={"comment":"Contient les images des corpus"})
*/
class Image
{
public function __toString(){
return $this->getTitle();
}
public function toArray()
{
return [
'title' => $this->getTitle(),
'corpus' => $this->getCorpus() != null ? $this->getCorpus()->toArray() : null,
'position' => $this->getPosition(),
'thumbnails' => 'https://'.$_ENV['BASE_URL'].'/image/thumbnails/'.$this->getId(),
'highres' => 'https://'.$_ENV['BASE_URL'].'/image/highres/'.$this->getId(),
'author' => $this->getAuthor(),
'arkLink' => $this->getArkLink(),
'longName' => $this->getLongName(),
'active' => $this->getActive(),
'lastUpdate' => $this->getLastUpdate(),
];
}
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer", options={"comment":"Identifiant unique de l'image"})
*/
private $id;
/**
* @ORM\Column(type="boolean", options={"comment":"Indique si l'image est active ou non"})
*/
private $active = true;
/**
* @ORM\Column(type="integer", options={"comment":"Position de l'image dans le corpus"})
*/
private $position = 1;
/**
* @ORM\ManyToOne(targetEntity=Corpus::class, inversedBy="images")
*/
private $corpus;
/**
* @ORM\Column(type="string", nullable=true, options={"comment":"Titre de l'image"})
*/
private $title;
/**
* @ORM\Column(type="string", nullable=true, options={"comment":"Auteur de l'image"})
*/
private $author;
/**
* @ORM\Column(type="string", nullable=true, options={"comment":"Lien ARK de l'image"})
*/
private $arkLink;
/**
* @ORM\Column(type="string", nullable=true, options={"comment":"Nom long de l'image"})
*/
private $longName;
/**
* @ORM\Column(type="string", nullable=true, options={"comment":"Nom du fichier highres"})
*/
private $highres;
/**
* @Vich\UploadableField(mapping="corpusPicture", fileNameProperty="highres")
* @var File
*/
private $highresFile;
/**
* @ORM\Column(type="string", options={"comment":"Nom du fichier thumbnails"})
*/
private $thumbnails;
/**
* @Vich\UploadableField(mapping="corpusPicture", fileNameProperty="thumbnails")
* @var File
*/
private $thumbnailsFile;
/**
* @ORM\Column(type="datetime", nullable=true, options={"comment":"Date de dernière mise à jour"})
*/
private $lastUpdate;
/**
* @return mixed
*/
public function getLastUpdate()
{
return $this->lastUpdate;
}
/**
* @param mixed $lastUpdate
*/
public function setLastUpdate($lastUpdate): void
{
$this->lastUpdate = $lastUpdate;
}
public function getId(): ?int
{
return $this->id;
}
public function getActive(): ?bool
{
return $this->active;
}
public function setActive(bool $active): self
{
$this->active = $active;
return $this;
}
/**
* @return mixed
*/
public function getPosition()
{
return $this->position;
}
/**
* @param mixed $position
*/
public function setPosition($position): void
{
$this->position = $position;
}
/**
* @return mixed
*/
public function getTitle()
{
return $this->title;
}
/**
* @param mixed $title
*/
public function setTitle($title): void
{
$this->title = $title;
}
/**
* @return mixed
*/
public function getAuthor()
{
return $this->author;
}
/**
* @param mixed $author
*/
public function setAuthor($author): void
{
$this->author = $author;
}
/**
* @return mixed
*/
public function getArkLink()
{
return $this->arkLink;
}
/**
* @param mixed $arkLink
*/
public function setArkLink($arkLink): void
{
$this->arkLink = $arkLink;
}
/**
* @return mixed
*/
public function getLongName()
{
return $this->longName;
}
/**
* @param mixed $longName
*/
public function setLongName($longName): void
{
$this->longName = $longName;
}
/**
* @return mixed
*/
public function getHighres()
{
return $this->highres;
}
/**
* @param mixed $highres
*/
public function setHighres($highres): void
{
$this->highres = $highres;
}
/**
* @return File
*/
public function getHighresFile(): File
{
return $this->highresFile;
}
/**
* @param File $highresFile
*/
public function setHighresFile(File $highresFile): void
{
$this->highresFile = $highresFile;
}
/**
* @return mixed
*/
public function getThumbnails()
{
return $this->thumbnails;
}
/**
* @param mixed $thumbnails
*/
public function setThumbnails($thumbnails): void
{
$this->thumbnails = $thumbnails;
}
/**
* @return File
*/
public function getThumbnailsFile(): File
{
return $this->thumbnailsFile;
}
/**
* @param File $thumbnailsFile
*/
public function setThumbnailsFile(File $thumbnailsFile): void
{
$this->thumbnailsFile = $thumbnailsFile;
}
/**
* @return mixed
*/
public function getCorpus()
{
return $this->corpus;
}
/**
* @param mixed $corpus
*/
public function setCorpus($corpus): void
{
$this->corpus = $corpus;
}
}