src/Entity/Video.php line 264

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Common\AutoTimestampTrait;
  4. use DateTime;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\HttpFoundation\File\File;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  11. use DateTimeImmutable;
  12. /**
  13.  * @ORM\Entity(repositoryClass="App\Repository\VideoRepository")
  14.  * @ORM\HasLifecycleCallbacks
  15.  * @Vich\Uploadable
  16.  */
  17. class Video
  18. {
  19.     use AutoTimestampTrait;
  20.     /**
  21.      * @ORM\Id()
  22.      * @ORM\GeneratedValue()
  23.      * @ORM\Column(type="integer")
  24.      */
  25.     private $id;
  26.     /**
  27.      * @ORM\Column(type="string", length=255)
  28.      */
  29.     private $titre;
  30.     /**
  31.      * @ORM\Column(type="string", length=255)
  32.      */
  33.     private $url;
  34.     /**
  35.      * @ORM\Column(type="boolean", options={"default" : false}, nullable=true)
  36.      */
  37.     private $actif;
  38.     /**
  39.      * @ORM\Column(type="integer", nullable=true)
  40.      */
  41.     private $position;
  42.     /**
  43.      * @ORM\Column(type="text", nullable=true)
  44.      */
  45.     private $texte;
  46.     /**
  47.      * @Assert\Image(
  48.      *     maxWidth=5000,
  49.      *     maxHeight=2813
  50.      * )
  51.      * @Vich\UploadableField(mapping="video", fileNameProperty="fileName", size="fileSize")
  52.      *
  53.      * @var File|null
  54.      */
  55.     private $videoFile;
  56.     /**
  57.      * @ORM\Column(type="string", nullable=true)
  58.      *
  59.      * @var string|null
  60.      */
  61.     private $fileName;
  62.     /**
  63.      * @ORM\Column(type="integer", nullable=true)
  64.      *
  65.      * @var int|null
  66.      */
  67.     private $fileSize;
  68.     /**
  69.      * @ORM\Column(type="datetime_immutable")
  70.      */
  71.     private $updatedAt;
  72.     /**
  73.      * @ORM\ManyToMany(targetEntity=Etablissement::class, inversedBy="videos", cascade={"merge"})
  74.      */
  75.     private $etablissements;
  76.     /**
  77.      * @Assert\Image(
  78.      *     maxWidth=5000,
  79.      *     maxHeight=2813
  80.      * )
  81.      * @Vich\UploadableField(mapping="video_source", fileNameProperty="fileNameSource", size="fileSizeSource")
  82.      *
  83.      * @var File|null
  84.      */
  85.     private $videoFileSource;
  86.     /**
  87.      * @ORM\Column(type="string", nullable=true)
  88.      *
  89.      * @var string|null
  90.      */
  91.     private $fileNameSource;
  92.     /**
  93.      * @ORM\Column(type="integer", nullable=true)
  94.      *
  95.      * @var int|null
  96.      */
  97.     private $fileSizeSource;
  98.     /**
  99.      * Video constructor.
  100.      */
  101.     public function __construct()
  102.     {
  103.         $this->updatedAt = new \DateTimeImmutable();
  104.         $this->etablissements = new ArrayCollection();
  105.     }
  106.     public function getId(): ?int
  107.     {
  108.         return $this->id;
  109.     }
  110.     public function getTitre(): ?string
  111.     {
  112.         return $this->titre;
  113.     }
  114.     public function setTitre(string $titre): self
  115.     {
  116.         $this->titre $titre;
  117.         return $this;
  118.     }
  119.     public function getUrl(): ?string
  120.     {
  121.         return $this->url;
  122.     }
  123.     public function setUrl(string $url): self
  124.     {
  125.         $this->url $url;
  126.         return $this;
  127.     }
  128.     public function getActif(): ?bool
  129.     {
  130.         return $this->actif;
  131.     }
  132.     public function setActif(bool $actif): self
  133.     {
  134.         $this->actif $actif;
  135.         return $this;
  136.     }
  137.     public function getPosition(): ?int
  138.     {
  139.         return $this->position;
  140.     }
  141.     public function setPosition(?int $position): self
  142.     {
  143.         $this->position $position;
  144.         return $this;
  145.     }
  146.     public function getTexte(): ?string
  147.     {
  148.         return $this->texte;
  149.     }
  150.     public function setTexte(?string $texte): self
  151.     {
  152.         $this->texte $texte;
  153.         return $this;
  154.     }
  155.     /**
  156.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  157.      * of 'UploadedFile' is injected into this setter to trigger the update. If this
  158.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  159.      * must be able to accept an instance of 'File' as the bundle will inject one here
  160.      * during Doctrine hydration.
  161.      *
  162.      * @param File|null $videoFile
  163.      */
  164.     public function setVideoFile(?File $videoFile null): void
  165.     {
  166.         $this->videoFile $videoFile;
  167.         if (null !== $videoFile) {
  168.             // It is required that at least one field changes if you are using doctrine
  169.             // otherwise the event listeners won't be called and the file is lost
  170.             $this->updatedAt = new DateTimeImmutable();
  171.         }
  172.     }
  173.     public function getVideoFile(): ?File
  174.     {
  175.         return $this->videoFile;
  176.     }
  177.     public function setFileName(?string $fileName): void
  178.     {
  179.         $this->fileName $fileName;
  180.     }
  181.     public function getFileName(): ?string
  182.     {
  183.         return $this->fileName;
  184.     }
  185.     public function setFileSize(?int $fileSize): void
  186.     {
  187.         $this->fileSize $fileSize;
  188.     }
  189.     public function getFileSize(): ?int
  190.     {
  191.         return $this->fileSize;
  192.     }
  193.     /**
  194.      * @return Collection<int, Etablissement>
  195.      */
  196.     public function getEtablissements(): Collection
  197.     {
  198.         return $this->etablissements;
  199.     }
  200.     public function addEtablissement(Etablissement $etablissement): self
  201.     {
  202.         if (!$this->etablissements->contains($etablissement)) {
  203.             $this->etablissements[] = $etablissement;
  204.         }
  205.         return $this;
  206.     }
  207.     public function removeEtablissement(Etablissement $etablissement): self
  208.     {
  209.         $this->etablissements->removeElement($etablissement);
  210.         return $this;
  211.     }
  212.     public function getEtablissement() {
  213.         return $this->etablissements[0];
  214.     }
  215.     /**
  216.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  217.      * of 'UploadedFile' is injected into this setter to trigger the update. If this
  218.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  219.      * must be able to accept an instance of 'File' as the bundle will inject one here
  220.      * during Doctrine hydration.
  221.      *
  222.      * @param File|null $videoFileSource
  223.      */
  224.     public function setVideoFileSource(?File $videoFileSource null): void
  225.     {
  226.         $this->videoFileSource $videoFileSource;
  227.         if (null !== $videoFileSource) {
  228.             // It is required that at least one field changes if you are using doctrine
  229.             // otherwise the event listeners won't be called and the file is lost
  230.             $this->updatedAt = new DateTimeImmutable();
  231.         }
  232.     }
  233.     public function getVideoFileSource(): ?File
  234.     {
  235.         return $this->videoFileSource;
  236.     }
  237.     public function setFileNameSource(?string $fileNameSource): void
  238.     {
  239.         $this->fileNameSource $fileNameSource;
  240.     }
  241.     public function getFileNameSource(): ?string
  242.     {
  243.         return $this->fileNameSource;
  244.     }
  245.     public function setFileSizeSource(?int $fileSizeSource): void
  246.     {
  247.         $this->fileSizeSource $fileSizeSource;
  248.     }
  249.     public function getFileSizeSource(): ?int
  250.     {
  251.         return $this->fileSizeSource;
  252.     }
  253. }