src/Entity/Image.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ImageRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\HttpFoundation\File\File;
  6. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  7. /**
  8.  * @ORM\Entity(repositoryClass=ImageRepository::class)
  9.  * @ORM\Table(name="image_corpus", schema="bdnf", options={"comment":"Contient les images des corpus"})
  10.  */
  11. class Image
  12. {
  13.     public function __toString(){
  14.         return $this->getTitle();
  15.     }
  16.     public function toArray()
  17.     {
  18.         return [
  19.             'title' => $this->getTitle(),
  20.             'corpus' => $this->getCorpus() != null $this->getCorpus()->toArray() : null,
  21.             'position' => $this->getPosition(),
  22.             'thumbnails' => 'https://'.$_ENV['BASE_URL'].'/image/thumbnails/'.$this->getId(),
  23.             'highres' => 'https://'.$_ENV['BASE_URL'].'/image/highres/'.$this->getId(),
  24.             'author' => $this->getAuthor(),
  25.             'arkLink' => $this->getArkLink(),
  26.             'longName' => $this->getLongName(),
  27.             'active' => $this->getActive(),
  28.             'lastUpdate' => $this->getLastUpdate(),
  29.         ];
  30.     }
  31.     /**
  32.      * @ORM\Id
  33.      * @ORM\GeneratedValue
  34.      * @ORM\Column(type="integer", options={"comment":"Identifiant unique de l'image"})
  35.      */
  36.     private $id;
  37.     /**
  38.      * @ORM\Column(type="boolean", options={"comment":"Indique si l'image est active ou non"})
  39.      */
  40.     private $active true;
  41.     /**
  42.      * @ORM\Column(type="integer", options={"comment":"Position de l'image dans le corpus"})
  43.      */
  44.     private $position 1;
  45.     /**
  46.      * @ORM\ManyToOne(targetEntity=Corpus::class, inversedBy="images")
  47.      */
  48.     private $corpus;
  49.     /**
  50.      * @ORM\Column(type="string", nullable=true, options={"comment":"Titre de l'image"})
  51.      */
  52.     private $title;
  53.     /**
  54.      * @ORM\Column(type="string", nullable=true, options={"comment":"Auteur de l'image"})
  55.      */
  56.     private $author;
  57.     /**
  58.      * @ORM\Column(type="string", nullable=true, options={"comment":"Lien ARK de l'image"})
  59.      */
  60.     private $arkLink;
  61.     /**
  62.      * @ORM\Column(type="string", nullable=true, options={"comment":"Nom long de l'image"})
  63.      */
  64.     private $longName;
  65.     /**
  66.      * @ORM\Column(type="string", nullable=true, options={"comment":"Nom du fichier highres"})
  67.      */
  68.     private $highres;
  69.     /**
  70.      * @Vich\UploadableField(mapping="corpusPicture", fileNameProperty="highres")
  71.      * @var File
  72.      */
  73.     private $highresFile;
  74.     /**
  75.      * @ORM\Column(type="string", options={"comment":"Nom du fichier thumbnails"})
  76.      */
  77.     private $thumbnails;
  78.     /**
  79.      * @Vich\UploadableField(mapping="corpusPicture", fileNameProperty="thumbnails")
  80.      * @var File
  81.      */
  82.     private $thumbnailsFile;
  83.     /**
  84.      * @ORM\Column(type="datetime", nullable=true, options={"comment":"Date de dernière mise à jour"})
  85.      */
  86.     private $lastUpdate;
  87.     /**
  88.      * @return mixed
  89.      */
  90.     public function getLastUpdate()
  91.     {
  92.         return $this->lastUpdate;
  93.     }
  94.     /**
  95.      * @param mixed $lastUpdate
  96.      */
  97.     public function setLastUpdate($lastUpdate): void
  98.     {
  99.         $this->lastUpdate $lastUpdate;
  100.     }
  101.     public function getId(): ?int
  102.     {
  103.         return $this->id;
  104.     }
  105.     public function getActive(): ?bool
  106.     {
  107.         return $this->active;
  108.     }
  109.     public function setActive(bool $active): self
  110.     {
  111.         $this->active $active;
  112.         return $this;
  113.     }
  114.     /**
  115.      * @return mixed
  116.      */
  117.     public function getPosition()
  118.     {
  119.         return $this->position;
  120.     }
  121.     /**
  122.      * @param mixed $position
  123.      */
  124.     public function setPosition($position): void
  125.     {
  126.         $this->position $position;
  127.     }
  128.     /**
  129.      * @return mixed
  130.      */
  131.     public function getTitle()
  132.     {
  133.         return $this->title;
  134.     }
  135.     /**
  136.      * @param mixed $title
  137.      */
  138.     public function setTitle($title): void
  139.     {
  140.         $this->title $title;
  141.     }
  142.     /**
  143.      * @return mixed
  144.      */
  145.     public function getAuthor()
  146.     {
  147.         return $this->author;
  148.     }
  149.     /**
  150.      * @param mixed $author
  151.      */
  152.     public function setAuthor($author): void
  153.     {
  154.         $this->author $author;
  155.     }
  156.     /**
  157.      * @return mixed
  158.      */
  159.     public function getArkLink()
  160.     {
  161.         return $this->arkLink;
  162.     }
  163.     /**
  164.      * @param mixed $arkLink
  165.      */
  166.     public function setArkLink($arkLink): void
  167.     {
  168.         $this->arkLink $arkLink;
  169.     }
  170.     /**
  171.      * @return mixed
  172.      */
  173.     public function getLongName()
  174.     {
  175.         return $this->longName;
  176.     }
  177.     /**
  178.      * @param mixed $longName
  179.      */
  180.     public function setLongName($longName): void
  181.     {
  182.         $this->longName $longName;
  183.     }
  184.     /**
  185.      * @return mixed
  186.      */
  187.     public function getHighres()
  188.     {
  189.         return $this->highres;
  190.     }
  191.     /**
  192.      * @param mixed $highres
  193.      */
  194.     public function setHighres($highres): void
  195.     {
  196.         $this->highres $highres;
  197.     }
  198.     /**
  199.      * @return File
  200.      */
  201.     public function getHighresFile(): File
  202.     {
  203.         return $this->highresFile;
  204.     }
  205.     /**
  206.      * @param File $highresFile
  207.      */
  208.     public function setHighresFile(File $highresFile): void
  209.     {
  210.         $this->highresFile $highresFile;
  211.     }
  212.     /**
  213.      * @return mixed
  214.      */
  215.     public function getThumbnails()
  216.     {
  217.         return $this->thumbnails;
  218.     }
  219.     /**
  220.      * @param mixed $thumbnails
  221.      */
  222.     public function setThumbnails($thumbnails): void
  223.     {
  224.         $this->thumbnails $thumbnails;
  225.     }
  226.     /**
  227.      * @return File
  228.      */
  229.     public function getThumbnailsFile(): File
  230.     {
  231.         return $this->thumbnailsFile;
  232.     }
  233.     /**
  234.      * @param File $thumbnailsFile
  235.      */
  236.     public function setThumbnailsFile(File $thumbnailsFile): void
  237.     {
  238.         $this->thumbnailsFile $thumbnailsFile;
  239.     }
  240.     /**
  241.      * @return mixed
  242.      */
  243.     public function getCorpus()
  244.     {
  245.         return $this->corpus;
  246.     }
  247.     /**
  248.      * @param mixed $corpus
  249.      */
  250.     public function setCorpus($corpus): void
  251.     {
  252.         $this->corpus $corpus;
  253.     }
  254. }