src/Entity/Resource.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ResourceRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\HttpFoundation\File\File;
  6. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  7. /**
  8.  * @Vich\Uploadable()
  9.  * @ORM\Entity(repositoryClass=ResourceRepository::class)
  10.  */
  11. class Resource
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\Column(type="string", length=1024)
  21.      */
  22.     private $fileName;
  23.     /**
  24.      * @var File $file
  25.      * @Vich\UploadableField(fileNameProperty="fileName", mapping="resources")
  26.      */
  27.     private $file;
  28.     /**
  29.      * @ORM\Column(type="datetime_immutable")
  30.      */
  31.     private $updatedAt;
  32.     /**
  33.      * @ORM\Column(type="string", length=1024)
  34.      */
  35.     private $originalName;
  36.     public function getId(): ?int
  37.     {
  38.         return $this->id;
  39.     }
  40.     public function getFileName(): ?string
  41.     {
  42.         return $this->fileName;
  43.     }
  44.     public function setFileName(string $fileName): self
  45.     {
  46.         $this->fileName $fileName;
  47.         return $this;
  48.     }
  49.     public function getUpdatedAt(): ?\DateTimeImmutable
  50.     {
  51.         return $this->updatedAt;
  52.     }
  53.     public function setUpdatedAt(\DateTimeImmutable $updatedAt): self
  54.     {
  55.         $this->updatedAt $updatedAt;
  56.         return $this;
  57.     }
  58.     /**
  59.      * @return File
  60.      */
  61.     public function getFile()
  62.     {
  63.         return $this->file;
  64.     }
  65.     /**
  66.      * @param File $file
  67.      */
  68.     public function setFile(File $file): void
  69.     {
  70.         $this->file $file;
  71.         if ($file) {
  72.             $this->updatedAt = new \DateTimeImmutable();
  73.         }
  74.     }
  75.     public function getOriginalName(): ?string
  76.     {
  77.         return $this->originalName;
  78.     }
  79.     public function setOriginalName(string $originalName): self
  80.     {
  81.         $this->originalName $originalName;
  82.         return $this;
  83.     }
  84. }