<?php
namespace App\Entity;
use App\Entity\Common\AutoTimestampTrait;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use DateTimeImmutable;
/**
* @ORM\Entity(repositoryClass="App\Repository\VideoRepository")
* @ORM\HasLifecycleCallbacks
* @Vich\Uploadable
*/
class Video
{
use AutoTimestampTrait;
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $titre;
/**
* @ORM\Column(type="string", length=255)
*/
private $url;
/**
* @ORM\Column(type="boolean", options={"default" : false}, nullable=true)
*/
private $actif;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $position;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $texte;
/**
* @Assert\Image(
* maxWidth=5000,
* maxHeight=2813
* )
* @Vich\UploadableField(mapping="video", fileNameProperty="fileName", size="fileSize")
*
* @var File|null
*/
private $videoFile;
/**
* @ORM\Column(type="string", nullable=true)
*
* @var string|null
*/
private $fileName;
/**
* @ORM\Column(type="integer", nullable=true)
*
* @var int|null
*/
private $fileSize;
/**
* @ORM\Column(type="datetime_immutable")
*/
private $updatedAt;
/**
* @ORM\ManyToMany(targetEntity=Etablissement::class, inversedBy="videos", cascade={"merge"})
*/
private $etablissements;
/**
* @Assert\Image(
* maxWidth=5000,
* maxHeight=2813
* )
* @Vich\UploadableField(mapping="video_source", fileNameProperty="fileNameSource", size="fileSizeSource")
*
* @var File|null
*/
private $videoFileSource;
/**
* @ORM\Column(type="string", nullable=true)
*
* @var string|null
*/
private $fileNameSource;
/**
* @ORM\Column(type="integer", nullable=true)
*
* @var int|null
*/
private $fileSizeSource;
/**
* Video constructor.
*/
public function __construct()
{
$this->updatedAt = new \DateTimeImmutable();
$this->etablissements = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getTitre(): ?string
{
return $this->titre;
}
public function setTitre(string $titre): self
{
$this->titre = $titre;
return $this;
}
public function getUrl(): ?string
{
return $this->url;
}
public function setUrl(string $url): self
{
$this->url = $url;
return $this;
}
public function getActif(): ?bool
{
return $this->actif;
}
public function setActif(bool $actif): self
{
$this->actif = $actif;
return $this;
}
public function getPosition(): ?int
{
return $this->position;
}
public function setPosition(?int $position): self
{
$this->position = $position;
return $this;
}
public function getTexte(): ?string
{
return $this->texte;
}
public function setTexte(?string $texte): self
{
$this->texte = $texte;
return $this;
}
/**
* If manually uploading a file (i.e. not using Symfony Form) ensure an instance
* of 'UploadedFile' is injected into this setter to trigger the update. If this
* bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
* must be able to accept an instance of 'File' as the bundle will inject one here
* during Doctrine hydration.
*
* @param File|null $videoFile
*/
public function setVideoFile(?File $videoFile = null): void
{
$this->videoFile = $videoFile;
if (null !== $videoFile) {
// It is required that at least one field changes if you are using doctrine
// otherwise the event listeners won't be called and the file is lost
$this->updatedAt = new DateTimeImmutable();
}
}
public function getVideoFile(): ?File
{
return $this->videoFile;
}
public function setFileName(?string $fileName): void
{
$this->fileName = $fileName;
}
public function getFileName(): ?string
{
return $this->fileName;
}
public function setFileSize(?int $fileSize): void
{
$this->fileSize = $fileSize;
}
public function getFileSize(): ?int
{
return $this->fileSize;
}
/**
* @return Collection<int, Etablissement>
*/
public function getEtablissements(): Collection
{
return $this->etablissements;
}
public function addEtablissement(Etablissement $etablissement): self
{
if (!$this->etablissements->contains($etablissement)) {
$this->etablissements[] = $etablissement;
}
return $this;
}
public function removeEtablissement(Etablissement $etablissement): self
{
$this->etablissements->removeElement($etablissement);
return $this;
}
public function getEtablissement() {
return $this->etablissements[0];
}
/**
* If manually uploading a file (i.e. not using Symfony Form) ensure an instance
* of 'UploadedFile' is injected into this setter to trigger the update. If this
* bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
* must be able to accept an instance of 'File' as the bundle will inject one here
* during Doctrine hydration.
*
* @param File|null $videoFileSource
*/
public function setVideoFileSource(?File $videoFileSource = null): void
{
$this->videoFileSource = $videoFileSource;
if (null !== $videoFileSource) {
// It is required that at least one field changes if you are using doctrine
// otherwise the event listeners won't be called and the file is lost
$this->updatedAt = new DateTimeImmutable();
}
}
public function getVideoFileSource(): ?File
{
return $this->videoFileSource;
}
public function setFileNameSource(?string $fileNameSource): void
{
$this->fileNameSource = $fileNameSource;
}
public function getFileNameSource(): ?string
{
return $this->fileNameSource;
}
public function setFileSizeSource(?int $fileSizeSource): void
{
$this->fileSizeSource = $fileSizeSource;
}
public function getFileSizeSource(): ?int
{
return $this->fileSizeSource;
}
}