src/Entity/FileStorage.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Tag\HasAuthToken;
  4. use App\Entity\Traits\AuthTokenTrait;
  5. use App\Repository\FileStorageRepository;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Timestampable\Traits\TimestampableEntity;
  8. use Symfony\Component\HttpFoundation\File\File;
  9. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  10. /**
  11. * @Vich\Uploadable
  12. */
  13. #[ORM\Table]
  14. #[ORM\Index(name: 'auth_token', columns: ['auth_token'])]
  15. #[ORM\Index(name: 'file_name', columns: ['file_name'])]
  16. #[ORM\Entity(repositoryClass: FileStorageRepository::class)]
  17. class FileStorage implements HasAuthToken
  18. {
  19. use AuthTokenTrait;
  20. use TimestampableEntity;
  21. #[ORM\Id]
  22. #[ORM\GeneratedValue]
  23. #[ORM\Column(type: 'integer')]
  24. private $id;
  25. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  26. private $mimeType;
  27. #[ORM\Column(type: 'integer')]
  28. private $fileSize;
  29. /**
  30. * NOTE: This is not a mapped field of entity metadata, just a simple property.
  31. *
  32. * @Vich\UploadableField(mapping="file_object", fileNameProperty="fileName", size="fileSize", mimeType="mimeType", originalName="sourceName")
  33. *
  34. * @var File|null
  35. */
  36. private $file;
  37. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  38. private $fileName;
  39. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  40. private $sourceName;
  41. public function getId(): ?int
  42. {
  43. return $this->id;
  44. }
  45. /**
  46. * @return mixed
  47. */
  48. public function getMimeType()
  49. {
  50. return $this->mimeType;
  51. }
  52. /**
  53. * @param mixed $mimeType
  54. *
  55. * @return FileStorage
  56. */
  57. public function setMimeType($mimeType)
  58. {
  59. $this->mimeType = $mimeType;
  60. return $this;
  61. }
  62. /**
  63. * @return mixed
  64. */
  65. public function getFileSize()
  66. {
  67. return $this->fileSize;
  68. }
  69. /**
  70. * @param mixed $fileSize
  71. *
  72. * @return FileStorage
  73. */
  74. public function setFileSize($fileSize)
  75. {
  76. $this->fileSize = $fileSize;
  77. return $this;
  78. }
  79. /**
  80. * @return File|null
  81. */
  82. public function getFile(): ?File
  83. {
  84. return $this->file;
  85. }
  86. /**
  87. * @param File|null $file
  88. *
  89. * @return FileStorage
  90. */
  91. public function setFile(?File $file): FileStorage
  92. {
  93. $this->file = $file;
  94. if ($this->file !== null) {
  95. $this->setUpdatedAt(new \DateTime());
  96. }
  97. return $this;
  98. }
  99. /**
  100. * @return mixed
  101. */
  102. public function getFileName()
  103. {
  104. return $this->fileName;
  105. }
  106. /**
  107. * @param mixed $fileName
  108. *
  109. * @return FileStorage
  110. */
  111. public function setFileName($fileName)
  112. {
  113. $this->fileName = $fileName;
  114. return $this;
  115. }
  116. /**
  117. * @return mixed
  118. */
  119. public function getSourceName()
  120. {
  121. return $this->sourceName;
  122. }
  123. /**
  124. * @param mixed $sourceName
  125. *
  126. * @return FileStorage
  127. */
  128. public function setSourceName($sourceName)
  129. {
  130. $this->sourceName = $sourceName;
  131. return $this;
  132. }
  133. }