PageRenderTime 48ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/src/FileBank/Entity/File.php

https://github.com/tawfekov/FileBank
PHP | 263 lines | 101 code | 30 blank | 132 comment | 1 complexity | 275dc6f03637d4393a8cdc6145983a54 MD5 | raw file
  1. <?php
  2. namespace FileBank\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use FileBank\Entity\Keyword;
  6. /**
  7. * File entity.
  8. *
  9. * @ORM\Entity
  10. * @ORM\Table(name="filebank")
  11. * @property int $id
  12. * @property string $name
  13. * @property int $size
  14. * @property string $mimetype
  15. * @property string $isactive
  16. * @property string $savepath
  17. * @property ArrayCollection $keywords
  18. */
  19. class File
  20. {
  21. /**
  22. * Default constructor, initializes collections
  23. */
  24. public function __construct()
  25. {
  26. $this->keywords = new ArrayCollection();
  27. }
  28. /**
  29. * @ORM\Id
  30. * @ORM\Column(type="integer");
  31. * @ORM\GeneratedValue(strategy="AUTO")
  32. */
  33. protected $id;
  34. /**
  35. * @ORM\Column(type="string")
  36. */
  37. protected $name;
  38. /**
  39. * @ORM\Column(type="integer")
  40. */
  41. protected $size;
  42. /**
  43. * @ORM\Column(type="string")
  44. */
  45. protected $mimetype;
  46. /**
  47. * @ORM\Column(type="integer")
  48. */
  49. protected $isactive;
  50. /**
  51. * @ORM\Column(type="string")
  52. */
  53. protected $savepath;
  54. /**
  55. * @ORM\OneToMany(targetEntity="FileBank\Entity\Keyword", mappedBy="file")
  56. * @ORM\OrderBy({"id" = "ASC"})
  57. * @var \Doctrine\Common\Collections\ArrayCollection
  58. */
  59. protected $keywords;
  60. /**
  61. * @var string $downloadUrl
  62. */
  63. protected $url;
  64. /**
  65. * Getter for the file id
  66. *
  67. * @return int
  68. */
  69. public function getId()
  70. {
  71. return $this->id;
  72. }
  73. /**
  74. * Setter for the file id
  75. *
  76. * @param int $value
  77. */
  78. public function setId($value)
  79. {
  80. $this->id = $value;
  81. }
  82. /**
  83. * Getter for the file name
  84. *
  85. * @return string
  86. */
  87. public function getName()
  88. {
  89. return $this->name;
  90. }
  91. /**
  92. * Setter for the file name
  93. *
  94. * @param string $value
  95. */
  96. public function setName($value)
  97. {
  98. $this->name = $value;
  99. }
  100. /**
  101. * Getter for the file size
  102. *
  103. * @return int
  104. */
  105. public function getSize()
  106. {
  107. return $this->size;
  108. }
  109. /**
  110. * Setter for the file size
  111. *
  112. * @param int $value
  113. */
  114. public function setSize($value)
  115. {
  116. $this->size = $value;
  117. }
  118. /**
  119. * Getter for the file mimetype
  120. *
  121. * @return string
  122. */
  123. public function getMimetype()
  124. {
  125. return $this->mimetype;
  126. }
  127. /**
  128. * Setter for the file mimetype
  129. *
  130. * @param int $value
  131. */
  132. public function setMimetype($value)
  133. {
  134. $this->mimetype = $value;
  135. }
  136. /**
  137. * Getter for the file's active status
  138. *
  139. * @return int
  140. */
  141. public function getIsActive()
  142. {
  143. return $this->isactive;
  144. }
  145. /**
  146. * Setter for the file's active status
  147. *
  148. * @param int $value
  149. */
  150. public function setIsActive($value)
  151. {
  152. $this->isactive = $value;
  153. }
  154. /**
  155. * Getter for the file's save path
  156. *
  157. * @return string
  158. */
  159. public function getSavePath()
  160. {
  161. return $this->savepath;
  162. }
  163. /**
  164. * Setter for the file's save path
  165. *
  166. * @param string $value
  167. */
  168. public function setSavePath($value)
  169. {
  170. $this->savepath = $value;
  171. }
  172. /**
  173. * Getter for the file's keywords
  174. *
  175. * @return \Doctrine\Common\Collections\ArrayCollection
  176. */
  177. public function getKeywords()
  178. {
  179. return $this->keywords;
  180. }
  181. /**
  182. * Setter for the file's keywords
  183. */
  184. public function setKeywords(Array $keywords)
  185. {
  186. $this->keywords->clear();
  187. foreach ($keywords as $keyword) {
  188. if ($keyword instanceof FileBank\Entity\Keyword) {
  189. $this->keywords->add($keyword);
  190. }
  191. }
  192. }
  193. /**
  194. * Getter for the file's download URL
  195. *
  196. * @return string
  197. */
  198. public function getUrl()
  199. {
  200. return $this->url;
  201. }
  202. /**
  203. * Setter for the file's download URL
  204. *
  205. * @param string $value
  206. */
  207. public function setUrl($value)
  208. {
  209. $this->url = $value;
  210. }
  211. /**
  212. * Convert the object to an array.
  213. *
  214. * @return array
  215. */
  216. public function getArrayCopy()
  217. {
  218. return get_object_vars($this);
  219. }
  220. /**
  221. * Populate from an array.
  222. *
  223. * @param array $data
  224. */
  225. public function populate($data = array())
  226. {
  227. $this->setName($data['name']);
  228. $this->setSize($data['size']);
  229. $this->setMimetype($data['mimetype']);
  230. $this->setIsActive($data['isactive']);
  231. $this->setSavePath($data['savepath']);
  232. }
  233. }