Image.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. namespace Uploadable\Fixture\Entity;
  3. use Gedmo\Mapping\Annotation as Gedmo;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6. * @ORM\Entity
  7. * @Gedmo\Uploadable(pathMethod="getPath")
  8. */
  9. class Image
  10. {
  11. /**
  12. * @ORM\Column(name="id", type="integer")
  13. * @ORM\Id
  14. * @ORM\GeneratedValue(strategy="IDENTITY")
  15. */
  16. private $id;
  17. /**
  18. * @ORM\Column(name="title", type="string")
  19. */
  20. private $title;
  21. /**
  22. * @ORM\Column(name="path", type="string", nullable=true)
  23. * @Gedmo\UploadableFilePath
  24. */
  25. private $filePath;
  26. /**
  27. * @ORM\Column(name="size", type="decimal", nullable=true)
  28. * @Gedmo\UploadableFileSize
  29. */
  30. private $size;
  31. /**
  32. * @ORM\Column(name="mime_type", type="string", nullable=true)
  33. * @Gedmo\UploadableFileMimeType
  34. */
  35. private $mime;
  36. private $useBasePath = false;
  37. public function getId()
  38. {
  39. return $this->id;
  40. }
  41. public function setTitle($title)
  42. {
  43. $this->title = $title;
  44. }
  45. public function getTitle()
  46. {
  47. return $this->title;
  48. }
  49. public function setFilePath($filePath)
  50. {
  51. $this->filePath = $filePath;
  52. }
  53. public function getFilePath()
  54. {
  55. return $this->filePath;
  56. }
  57. public function getPath($basePath = null)
  58. {
  59. if ($this->useBasePath) {
  60. return $basePath.'/abc/def';
  61. }
  62. return __DIR__.'/../../../../temp/uploadable';
  63. }
  64. public function setMime($mime)
  65. {
  66. $this->mime = $mime;
  67. }
  68. public function getMime()
  69. {
  70. return $this->mime;
  71. }
  72. public function setSize($size)
  73. {
  74. $this->size = $size;
  75. }
  76. public function getSize()
  77. {
  78. return $this->size;
  79. }
  80. public function setUseBasePath($useBasePath)
  81. {
  82. $this->useBasePath = $useBasePath;
  83. }
  84. }