src/CoreBundle/Entity/WorksheetSolutionFile.php line 16

Open in your IDE?
  1. <?php
  2. namespace CoreBundle\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Component\HttpFoundation\File\File as File;
  5. use Symfony\Component\HttpFoundation\File\UploadedFile;
  6. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  7. /**
  8. * @ORM\Entity
  9. * @ORM\Table("worksheet_solution_file")
  10. * @Vich\Uploadable
  11. */
  12. class WorksheetSolutionFile extends SolutionFile
  13. {
  14. /**
  15. * @var WorksheetSolution
  16. *
  17. * @ORM\ManyToOne(targetEntity="WorksheetSolution", inversedBy="worksheetSolutionFiles")
  18. */
  19. private $worksheetSolution;
  20. /**
  21. * NOTE: This is not a mapped field of entity metadata, just a simple property.
  22. *
  23. * @Vich\UploadableField(mapping="worksheet_solution_file", fileNameProperty="fileName", originalName="originalName", size="fileSize", mimeType="mimeType")
  24. *
  25. * @var File
  26. */
  27. private $file;
  28. public function getWorksheetSolution(): WorksheetSolution
  29. {
  30. return $this->worksheetSolution;
  31. }
  32. public function setWorksheetSolution(WorksheetSolution $worksheetSolution)
  33. {
  34. $this->worksheetSolution = $worksheetSolution;
  35. }
  36. /**
  37. * @param File|UploadedFile $file
  38. * @throws \Exception
  39. */
  40. public function setFile(?File $file = null): void
  41. {
  42. $this->file = $file;
  43. if (null !== $file) {
  44. // It is required that at least one field changes if you are using doctrine
  45. // otherwise the event listeners won't be called and the file is lost
  46. $this->updatedAt = new \DateTimeImmutable();
  47. }
  48. }
  49. public function getFile(): ?File
  50. {
  51. return $this->file;
  52. }
  53. }