<?php
namespace App\Entity;
use DateTime;
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;
#[ORM\Entity(repositoryClass: 'App\Repository\VideoRepository')]
#[ORM\Table(name: 'video')]
#[Vich\Uploadable]
class Video
{
#[ORM\ManyToOne(targetEntity: 'App\Entity\Address', inversedBy: 'videos')]
#[ORM\JoinColumn(nullable: false)]
private Collection|array $address;
#[ORM\Column(name: 'createdAt', type: 'datetime')]
private DateTime $createdAt;
#[ORM\ManyToOne(targetEntity: 'App\Entity\DisasterDeclaration', inversedBy: 'videos', cascade: ['persist'])]
#[ORM\JoinColumn(nullable: true)]
private DisasterDeclaration $disasterDeclaration;
#[ORM\Column(name: 'id', type: 'integer')]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private ?int $id;
#[ORM\ManyToOne(targetEntity: 'App\Entity\User', inversedBy: 'videos')]
#[ORM\JoinColumn(nullable: false)]
private User $user;
#[ORM\Column(name: 'category', type: 'string', length: 255, nullable: true)]
private ?string $category;
#[ORM\Column(type: 'boolean')]
private bool $isDeleted = false;
#[Vich\UploadableField(mapping: 'video', fileNameProperty: 'videoFileName', size: 'videoFileSize')]
#[Assert\File(
maxSize: '10000k',
mimeTypes: ['video/mpeg', 'video/mp4', 'video/quicktime', 'video/x-ms-wmv', 'video/x-msvideo', 'video/x-flv']
)]
private File $videoFile;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $name;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $videoFileName;
#[ORM\Column(type: 'integer', nullable: true)]
private ?int $videoFileSize;
#[ORM\Column(type: 'datetime', nullable: true)]
private ?DateTime $videoFileUpdatedAt;
public function __construct() {
$this->createdAt = new \DateTime();
}
public static function getCategories() {
$arr = [
"Domicile principal" => "principal",
"Domicile secondaire" => "secondaire",
"Autres" => "autre",
];
return array_combine($arr, $arr);
}
public static function getNames() {
$arr = [
"Atelier",
"Balcon",
"Bibliothèque",
"Bureau",
"Cave",
"Cave à vin",
"Chambre enfant",
"Chambre parentale",
"Combles",
"Couloir",
"Cuisine",
"Dressing",
"Entrée",
"Garage en sous-sol",
"Garage extérieur",
"Grenier",
"Hall",
"Laverie",
"Local technique",
"Salle à manger",
"Salle d’eau",
"Salle de bain",
"Salle de jeux",
"Salon",
"Séjour",
"Sous-sol",
"Terrasse ",
];
return array_combine($arr, $arr);
}
public function __toString() {
return "#" . $this->id . " - " . $this->name;
}
public function getVideoFile() {
return $this->videoFile;
}
/**
* 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|\Symfony\Component\HttpFoundation\File\UploadedFile $image
*/
public function setVideoFile(File $image = null) {
$this->videoFile = $image;
if (null !== $image) {
// 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->videoFileUpdatedAt = new \DateTime();
}
}
/**
* Get id
*
* @return int
*/
public function getId() {
return $this->id;
}
/**
* Get createdAt
*
* @return \DateTime
*/
public function getCreatedAt() {
return $this->createdAt;
}
/**
* Set createdAt
*
* @param \DateTime $createdAt
*
* @return Video
*/
public function setCreatedAt($createdAt) {
$this->createdAt = $createdAt;
return $this;
}
/**
* Get videoFileName
*
* @return string
*/
public function getVideoFileName() {
return $this->videoFileName;
}
/**
* Set videoFileName
*
* @param string $videoFileName
*
* @return Video
*/
public function setVideoFileName($videoFileName) {
$this->videoFileName = $videoFileName;
return $this;
}
/**
* Get videoFileSize
*
* @return integer
*/
public function getVideoFileSize() {
return $this->videoFileSize;
}
/**
* Set videoFileSize
*
* @param integer $videoFileSize
*
* @return Video
*/
public function setVideoFileSize($videoFileSize) {
$this->videoFileSize = $videoFileSize;
return $this;
}
/**
* Get videoFileUpdatedAt
*
* @return \DateTime
*/
public function getVideoFileUpdatedAt() {
return $this->videoFileUpdatedAt;
}
/**
* Set videoFileUpdatedAt
*
* @param \DateTime $videoFileUpdatedAt
*
* @return Video
*/
public function setVideoFileUpdatedAt($videoFileUpdatedAt) {
$this->videoFileUpdatedAt = $videoFileUpdatedAt;
return $this;
}
/**
* Get user
*
* @return \App\Entity\User
*/
public function getUser() {
return $this->user;
}
/**
* Set user
*
* @param \App\Entity\User $user
*
* @return Video
*/
public function setUser(\App\Entity\User $user) {
$this->user = $user;
return $this;
}
/**
* Get disasterDeclaration
*
* @return \App\Entity\DisasterDeclaration
*/
public function getDisasterDeclaration() {
return $this->disasterDeclaration;
}
/**
* Set disasterDeclaration
*
* @param \App\Entity\DisasterDeclaration $disasterDeclaration
*
* @return Video
*/
public function setDisasterDeclaration(\App\Entity\DisasterDeclaration $disasterDeclaration = null) {
$this->disasterDeclaration = $disasterDeclaration;
return $this;
}
/**
* Get isDeleted
*
* @return boolean
*/
public function getIsDeleted() {
return $this->isDeleted;
}
/**
* Set isDeleted
*
* @param boolean $isDeleted
*
* @return Video
*/
public function setIsDeleted($isDeleted) {
$this->isDeleted = $isDeleted;
return $this;
}
/**
* Get category
*
* @return string
*/
public function getCategory() {
return $this->category;
}
/**
* Set category
*
* @param string $category
*
* @return Video
*/
public function setCategory($category) {
$this->category = $category;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName() {
return $this->name;
}
/**
* Set name
*
* @param string $name
*
* @return Video
*/
public function setName($name) {
$this->name = $name;
return $this;
}
/**
* Get address
*
* @return \App\Entity\Address
*/
public function getAddress() {
return $this->address;
}
/**
* Set address
*
* @param \App\Entity\Address $address
*
* @return Video
*/
public function setAddress(\App\Entity\Address $address) {
$this->address = $address;
return $this;
}
}