bundle/w3des/AdminBundle/src/Entity/File.php line 12

Open in your IDE?
  1. <?php
  2. namespace w3des\AdminBundle\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Ramsey\Uuid\Uuid;
  5. /**
  6. * @ORM\Table()
  7. * @ORM\Entity()
  8. * @ORM\HasLifecycleCallbacks()
  9. */
  10. class File
  11. {
  12. /**
  13. * @ORM\Column(type="guid")
  14. * @ORM\Id
  15. */
  16. private $id;
  17. /**
  18. * @ORM\Column(type="string")
  19. */
  20. private $path;
  21. /**
  22. * @ORM\Column(type="string")
  23. */
  24. private $repository = 'default';
  25. /**
  26. * @ORM\Column(type="string")
  27. */
  28. private $mime;
  29. /**
  30. * @ORM\Column(type="integer")
  31. */
  32. private $size;
  33. /**
  34. * @ORM\Column(type="json")
  35. */
  36. private $meta = [];
  37. /**
  38. * @ORM\PrePersist()
  39. */
  40. public function prePersist()
  41. {
  42. $this->id = Uuid::uuid4()->toString();
  43. }
  44. /**
  45. * @return $path
  46. */
  47. public function getPath()
  48. {
  49. return $this->path;
  50. }
  51. /**
  52. * @param mixed $path
  53. */
  54. public function setPath($path)
  55. {
  56. $this->path = $path;
  57. }
  58. /**
  59. * @return $width
  60. */
  61. public function getWidth()
  62. {
  63. return $this->getMetaValue('width');
  64. }
  65. /**
  66. * @param mixed $width
  67. */
  68. public function setWidth($width)
  69. {
  70. $this->setMetaValue('width', (int)$width);
  71. }
  72. /**
  73. * @return $height
  74. */
  75. public function getHeight()
  76. {
  77. return $this->getMetaValue('height');
  78. }
  79. public function getMeta()
  80. {
  81. return $this->meta;
  82. }
  83. public function setMeta(array $meta)
  84. {
  85. $this->meta = $meta;
  86. }
  87. public function setMetaValue($k, $v)
  88. {
  89. $this->meta[$k] = $v;
  90. }
  91. public function getMetaValue($k)
  92. {
  93. if (isset($this->meta[$k])) {
  94. return $this->meta[$k];
  95. }
  96. return null;
  97. }
  98. /**
  99. * @param mixed $height
  100. */
  101. public function setHeight($height)
  102. {
  103. $this->setMetaValue('height', (int)$height);
  104. }
  105. /**
  106. * @return $mime
  107. */
  108. public function getMime()
  109. {
  110. return $this->mime;
  111. }
  112. /**
  113. * @param mixed $mime
  114. */
  115. public function setMime($mime)
  116. {
  117. $this->mime = $mime;
  118. }
  119. /**
  120. * @return $size
  121. */
  122. public function getSize()
  123. {
  124. return $this->size;
  125. }
  126. /**
  127. * @param mixed $size
  128. */
  129. public function setSize($size)
  130. {
  131. $this->size = $size;
  132. }
  133. /**
  134. * @return $repository
  135. */
  136. public function getRepository()
  137. {
  138. return $this->repository;
  139. }
  140. /**
  141. * @param string $repository
  142. */
  143. public function setRepository($repository)
  144. {
  145. $this->repository = $repository;
  146. }
  147. public function __toString()
  148. {
  149. return $this->getPath() . '';
  150. }
  151. public function getFile()
  152. {
  153. return $this->file;
  154. }
  155. public function isRemove()
  156. {
  157. return $this->remove;
  158. }
  159. /**
  160. * @return $id
  161. */
  162. public function getId()
  163. {
  164. return $this->id;
  165. }
  166. /**
  167. * @param string $id
  168. */
  169. public function setId($id)
  170. {
  171. $this->id = $id;
  172. }
  173. }