src/Entity/Video.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use DateTime;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\HttpFoundation\File\File;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  8. #[ORM\Entity(repositoryClass'App\Repository\VideoRepository')]
  9. #[ORM\Table(name'video')]
  10. #[Vich\Uploadable]
  11. class Video
  12. {
  13.     #[ORM\ManyToOne(targetEntity'App\Entity\Address'inversedBy'videos')]
  14.     #[ORM\JoinColumn(nullablefalse)]
  15.     private Collection|array $address;
  16.     #[ORM\Column(name'createdAt'type'datetime')]
  17.     private DateTime $createdAt;
  18.     #[ORM\ManyToOne(targetEntity'App\Entity\DisasterDeclaration'inversedBy'videos'cascade: ['persist'])]
  19.     #[ORM\JoinColumn(nullabletrue)]
  20.     private DisasterDeclaration $disasterDeclaration;
  21.     #[ORM\Column(name'id'type'integer')]
  22.     #[ORM\Id]
  23.     #[ORM\GeneratedValue(strategy'AUTO')]
  24.     private ?int $id;
  25.     #[ORM\ManyToOne(targetEntity'App\Entity\User'inversedBy'videos')]
  26.     #[ORM\JoinColumn(nullablefalse)]
  27.     private User $user;
  28.     #[ORM\Column(name'category'type'string'length255nullabletrue)]
  29.     private ?string $category;
  30.     #[ORM\Column(type'boolean')]
  31.     private bool $isDeleted false;
  32.     #[Vich\UploadableField(mapping'video'fileNameProperty'videoFileName'size'videoFileSize')]
  33.     #[Assert\File(
  34.         maxSize'10000k',
  35.         mimeTypes: ['video/mpeg''video/mp4''video/quicktime''video/x-ms-wmv''video/x-msvideo''video/x-flv']
  36.     )]
  37.     private File $videoFile;
  38.     #[ORM\Column(type'string'length255nullabletrue)]
  39.     private ?string $name;
  40.     #[ORM\Column(type'string'length255nullabletrue)]
  41.     private ?string $videoFileName;
  42.     #[ORM\Column(type'integer'nullabletrue)]
  43.     private ?int $videoFileSize;
  44.     #[ORM\Column(type'datetime'nullabletrue)]
  45.     private ?DateTime $videoFileUpdatedAt;
  46.     public function __construct() {
  47.         $this->createdAt = new \DateTime();
  48.     }
  49.     public static function getCategories() {
  50.         $arr = [
  51.             "Domicile principal" => "principal",
  52.             "Domicile secondaire" => "secondaire",
  53.             "Autres" => "autre",
  54.         ];
  55.         return array_combine($arr$arr);
  56.     }
  57.     public static function getNames() {
  58.         $arr = [
  59.             "Atelier",
  60.             "Balcon",
  61.             "Bibliothèque",
  62.             "Bureau",
  63.             "Cave",
  64.             "Cave à vin",
  65.             "Chambre enfant",
  66.             "Chambre parentale",
  67.             "Combles",
  68.             "Couloir",
  69.             "Cuisine",
  70.             "Dressing",
  71.             "Entrée",
  72.             "Garage en sous-sol",
  73.             "Garage extérieur",
  74.             "Grenier",
  75.             "Hall",
  76.             "Laverie",
  77.             "Local technique",
  78.             "Salle à manger",
  79.             "Salle d’eau",
  80.             "Salle de bain",
  81.             "Salle de jeux",
  82.             "Salon",
  83.             "Séjour",
  84.             "Sous-sol",
  85.             "Terrasse ",
  86.         ];
  87.         return array_combine($arr$arr);
  88.     }
  89.     public function __toString() {
  90.         return "#" $this->id " - " $this->name;
  91.     }
  92.     public function getVideoFile() {
  93.         return $this->videoFile;
  94.     }
  95.     /**
  96.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  97.      * of 'UploadedFile' is injected into this setter to trigger the  update. If this
  98.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  99.      * must be able to accept an instance of 'File' as the bundle will inject one here
  100.      * during Doctrine hydration.
  101.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile $image
  102.      */
  103.     public function setVideoFile(File $image null) {
  104.         $this->videoFile $image;
  105.         if (null !== $image) {
  106. // It is required that at least one field changes if you are using doctrine
  107. // otherwise the event listeners won't be called and the file is lost
  108.             $this->videoFileUpdatedAt = new \DateTime();
  109.         }
  110.     }
  111.     /**
  112.      * Get id
  113.      *
  114.      * @return int
  115.      */
  116.     public function getId() {
  117.         return $this->id;
  118.     }
  119.     /**
  120.      * Get createdAt
  121.      *
  122.      * @return \DateTime
  123.      */
  124.     public function getCreatedAt() {
  125.         return $this->createdAt;
  126.     }
  127.     /**
  128.      * Set createdAt
  129.      *
  130.      * @param \DateTime $createdAt
  131.      *
  132.      * @return Video
  133.      */
  134.     public function setCreatedAt($createdAt) {
  135.         $this->createdAt $createdAt;
  136.         return $this;
  137.     }
  138.     /**
  139.      * Get videoFileName
  140.      *
  141.      * @return string
  142.      */
  143.     public function getVideoFileName() {
  144.         return $this->videoFileName;
  145.     }
  146.     /**
  147.      * Set videoFileName
  148.      *
  149.      * @param string $videoFileName
  150.      *
  151.      * @return Video
  152.      */
  153.     public function setVideoFileName($videoFileName) {
  154.         $this->videoFileName $videoFileName;
  155.         return $this;
  156.     }
  157.     /**
  158.      * Get videoFileSize
  159.      *
  160.      * @return integer
  161.      */
  162.     public function getVideoFileSize() {
  163.         return $this->videoFileSize;
  164.     }
  165.     /**
  166.      * Set videoFileSize
  167.      *
  168.      * @param integer $videoFileSize
  169.      *
  170.      * @return Video
  171.      */
  172.     public function setVideoFileSize($videoFileSize) {
  173.         $this->videoFileSize $videoFileSize;
  174.         return $this;
  175.     }
  176.     /**
  177.      * Get videoFileUpdatedAt
  178.      *
  179.      * @return \DateTime
  180.      */
  181.     public function getVideoFileUpdatedAt() {
  182.         return $this->videoFileUpdatedAt;
  183.     }
  184.     /**
  185.      * Set videoFileUpdatedAt
  186.      *
  187.      * @param \DateTime $videoFileUpdatedAt
  188.      *
  189.      * @return Video
  190.      */
  191.     public function setVideoFileUpdatedAt($videoFileUpdatedAt) {
  192.         $this->videoFileUpdatedAt $videoFileUpdatedAt;
  193.         return $this;
  194.     }
  195.     /**
  196.      * Get user
  197.      *
  198.      * @return \App\Entity\User
  199.      */
  200.     public function getUser() {
  201.         return $this->user;
  202.     }
  203.     /**
  204.      * Set user
  205.      *
  206.      * @param \App\Entity\User $user
  207.      *
  208.      * @return Video
  209.      */
  210.     public function setUser(\App\Entity\User $user) {
  211.         $this->user $user;
  212.         return $this;
  213.     }
  214.     /**
  215.      * Get disasterDeclaration
  216.      *
  217.      * @return \App\Entity\DisasterDeclaration
  218.      */
  219.     public function getDisasterDeclaration() {
  220.         return $this->disasterDeclaration;
  221.     }
  222.     /**
  223.      * Set disasterDeclaration
  224.      *
  225.      * @param \App\Entity\DisasterDeclaration $disasterDeclaration
  226.      *
  227.      * @return Video
  228.      */
  229.     public function setDisasterDeclaration(\App\Entity\DisasterDeclaration $disasterDeclaration null) {
  230.         $this->disasterDeclaration $disasterDeclaration;
  231.         return $this;
  232.     }
  233.     /**
  234.      * Get isDeleted
  235.      *
  236.      * @return boolean
  237.      */
  238.     public function getIsDeleted() {
  239.         return $this->isDeleted;
  240.     }
  241.     /**
  242.      * Set isDeleted
  243.      *
  244.      * @param boolean $isDeleted
  245.      *
  246.      * @return Video
  247.      */
  248.     public function setIsDeleted($isDeleted) {
  249.         $this->isDeleted $isDeleted;
  250.         return $this;
  251.     }
  252.     /**
  253.      * Get category
  254.      *
  255.      * @return string
  256.      */
  257.     public function getCategory() {
  258.         return $this->category;
  259.     }
  260.     /**
  261.      * Set category
  262.      *
  263.      * @param string $category
  264.      *
  265.      * @return Video
  266.      */
  267.     public function setCategory($category) {
  268.         $this->category $category;
  269.         return $this;
  270.     }
  271.     /**
  272.      * Get name
  273.      *
  274.      * @return string
  275.      */
  276.     public function getName() {
  277.         return $this->name;
  278.     }
  279.     /**
  280.      * Set name
  281.      *
  282.      * @param string $name
  283.      *
  284.      * @return Video
  285.      */
  286.     public function setName($name) {
  287.         $this->name $name;
  288.         return $this;
  289.     }
  290.     /**
  291.      * Get address
  292.      *
  293.      * @return \App\Entity\Address
  294.      */
  295.     public function getAddress() {
  296.         return $this->address;
  297.     }
  298.     /**
  299.      * Set address
  300.      *
  301.      * @param \App\Entity\Address $address
  302.      *
  303.      * @return Video
  304.      */
  305.     public function setAddress(\App\Entity\Address $address) {
  306.         $this->address $address;
  307.         return $this;
  308.     }
  309. }