src/Entity/Quote/QuoteRequestFile.php line 16

  1. <?php
  2. namespace App\Entity\Quote;
  3. use App\Repository\Quote\QuoteRequestFileRepository;
  4. use Doctrine\DBAL\Types\Types;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\HttpFoundation\File\File;
  7. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  8. #[ORM\Entity(repositoryClassQuoteRequestFileRepository::class)]
  9. #[ORM\Table(name'app_quote_request_file')]
  10. #[Vich\Uploadable]
  11. class QuoteRequestFile
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column]
  15.     private ?int $id null
  16.     #[ORM\ManyToOne(inversedBy'files')]
  17.     private ?QuoteRequest $quote null;
  18.     #[ORM\ManyToOne]
  19.     private ?RequestFileType $type null;
  20.     #[ORM\Column(length255nullabletrue)]
  21.     private ?string $path null;
  22.     private ?string $url null;
  23.     #[ORM\Column(nullabletrue)]
  24.     private ?int $size null;
  25.     #[ORM\Column(length50)]
  26.     private ?string $mimeType null;
  27.     #[ORM\Column(length255)]
  28.     private ?string $originalName null;
  29.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  30.     private ?\DateTimeInterface $updatedAt null;
  31.     #[ORM\Column(typeTypes::ARRAY, nullabletrue)]
  32.     private ?array $dimensions = [];
  33.     // NOTE: This is not a mapped field of entity metadata, just a simple property.
  34.     #[Vich\UploadableField(mapping'quote_request_file'fileNameProperty'path'size'size'dimensions'dimensions'mimeType'mimeType'originalName'originalName')]
  35.     private ?File $file null;
  36.     /**
  37.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  38.      * of 'UploadedFile' is injected into this setter to trigger the update. If this
  39.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  40.      * must be able to accept an instance of 'File' as the bundle will inject one here
  41.      * during Doctrine hydration.
  42.      *
  43.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $imageFile
  44.      */
  45.     public function setFile(?File $file null): void
  46.     {
  47.         $this->file $file;
  48.         if (null !== $file) {
  49.             // It is required that at least one field changes if you are using doctrine
  50.             // otherwise the event listeners won't be called and the file is lost
  51.             $this->updatedAt = new \DateTimeImmutable();
  52.         }
  53.     }
  54.     public function getFile(): ?File
  55.     {
  56.         return $this->file;
  57.     }
  58.     public function getId(): ?int
  59.     {
  60.         return $this->id;
  61.     } 
  62.     public function getPath(): ?string
  63.     {
  64.         return $this->path;
  65.     }
  66.     public function setPath(?string $path): self
  67.     {
  68.         $this->path $path;
  69.         return $this;
  70.     }
  71.     public function getUrl(): ?string
  72.     {
  73.         return $this->url;
  74.     }
  75.     public function setUrl(string $url): self
  76.     {
  77.         $this->url $url;
  78.         return $this;
  79.     }
  80.     public function getSize(): ?int
  81.     {
  82.         return $this->size;
  83.     }
  84.     public function setSize(?int $size): self
  85.     {
  86.         $this->size $size;
  87.         return $this;
  88.     }
  89.     public function getMimeType(): ?string
  90.     {
  91.         return $this->mimeType;
  92.     }
  93.     public function setMimeType(string $mimeType): self
  94.     {
  95.         $this->mimeType $mimeType;
  96.         return $this;
  97.     }
  98.     public function getOriginalName(): ?string
  99.     {
  100.         return $this->originalName;
  101.     }
  102.     public function setOriginalName(string $originalName): self
  103.     {
  104.         $this->originalName $originalName;
  105.         return $this;
  106.     }
  107.     public function getUpdatedAt(): ?\DateTimeInterface
  108.     {
  109.         return $this->updatedAt;
  110.     }
  111.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  112.     {
  113.         $this->updatedAt $updatedAt;
  114.         return $this;
  115.     }
  116.     public function getDimensions(): array
  117.     {
  118.         return $this->dimensions;
  119.     }
  120.     public function setDimensions(?array $dimensions): self
  121.     {
  122.         $this->dimensions $dimensions;
  123.         return $this;
  124.     }
  125.     public function getQuote(): ?QuoteRequest
  126.     {
  127.         return $this->quote;
  128.     }
  129.     public function setQuote(?QuoteRequest $quote): self
  130.     {
  131.         $this->quote $quote;
  132.         return $this;
  133.     }
  134.     public function getType(): ?RequestFileType
  135.     {
  136.         return $this->type;
  137.     }
  138.     public function setType(?RequestFileType $type): self
  139.     {
  140.         $this->type $type;
  141.         return $this;
  142.     }
  143. }