1 | <?php |
||
19 | class PostEntity extends AbstractImageUpload |
||
20 | { |
||
21 | /** |
||
22 | * @var int |
||
23 | * |
||
24 | * @ORM\Column(name="id", type="integer") |
||
25 | * @ORM\Id |
||
26 | * @ORM\GeneratedValue(strategy="IDENTITY") |
||
27 | */ |
||
28 | protected $id; |
||
29 | |||
30 | /** |
||
31 | * @var string |
||
32 | * |
||
33 | * @ORM\Column(name="title", type="string", length=255) |
||
34 | */ |
||
35 | protected $title; |
||
36 | |||
37 | /** |
||
38 | * @var string |
||
39 | * |
||
40 | * @ORM\Column(name="content", type="text", nullable=true) |
||
41 | */ |
||
42 | protected $content; |
||
43 | |||
44 | /** |
||
45 | * @var string |
||
46 | * |
||
47 | * @ORM\Column(name="image_url", type="text", nullable=true) |
||
48 | */ |
||
49 | protected $imageUrl; |
||
50 | |||
51 | /** |
||
52 | * @var \DateTime |
||
53 | * |
||
54 | * @ORM\Column(name="time_created", type="datetime") |
||
55 | */ |
||
56 | protected $timeCreated; |
||
57 | |||
58 | /** |
||
59 | * @var \DateTime |
||
60 | * |
||
61 | * @ORM\Column(name="time_updated", type="datetime") |
||
62 | */ |
||
63 | protected $timeUpdated; |
||
64 | |||
65 | /** |
||
66 | * @ORM\ManyToOne(targetEntity="Application\Entity\UserEntity", inversedBy="posts") |
||
67 | */ |
||
68 | protected $user; |
||
69 | |||
70 | /** |
||
71 | * @var ArrayCollection |
||
72 | * |
||
73 | * @ORM\OneToMany(targetEntity="Application\Entity\PostMetaEntity", mappedBy="post", cascade={"all"}) |
||
74 | */ |
||
75 | protected $postMetas; |
||
76 | |||
77 | /** |
||
78 | * Helper for metas. |
||
79 | * |
||
80 | * @var array |
||
81 | */ |
||
82 | protected $metas; |
||
83 | |||
84 | /** |
||
85 | * @var bool |
||
86 | */ |
||
87 | protected $removeImage = false; |
||
88 | |||
89 | /** |
||
90 | * Constructor. |
||
91 | */ |
||
92 | public function __construct() |
||
96 | |||
97 | /*** Id ***/ |
||
98 | /** |
||
99 | * @return int |
||
100 | */ |
||
101 | public function getId() |
||
105 | |||
106 | /** |
||
107 | * @param int $id |
||
108 | * |
||
109 | * @return PostEntity |
||
110 | */ |
||
111 | public function setId($id) |
||
117 | |||
118 | /*** Title ***/ |
||
119 | /** |
||
120 | * @return string |
||
121 | */ |
||
122 | public function getTitle() |
||
126 | |||
127 | /** |
||
128 | * @param string $title |
||
129 | * |
||
130 | * @return PostEntity |
||
131 | */ |
||
132 | public function setTitle($title) |
||
138 | |||
139 | /*** Content ***/ |
||
140 | /** |
||
141 | * @return string |
||
142 | */ |
||
143 | public function getContent() |
||
147 | |||
148 | /** |
||
149 | * @param string $content |
||
150 | * |
||
151 | * @return PostEntity |
||
152 | */ |
||
153 | public function setContent($content) |
||
159 | |||
160 | /*** Time created ***/ |
||
161 | /** |
||
162 | * @return \DateTime |
||
163 | */ |
||
164 | public function getTimeCreated() |
||
168 | |||
169 | /** |
||
170 | * @param \DateTime $timeCreated |
||
171 | * |
||
172 | * @return PostEntity |
||
173 | */ |
||
174 | public function setTimeCreated(\DateTime $timeCreated) |
||
180 | |||
181 | /*** Time updated ***/ |
||
182 | /** |
||
183 | * @return \DateTime |
||
184 | */ |
||
185 | public function getTimeUpdated() |
||
189 | |||
190 | /** |
||
191 | * @param \DateTime $timeUpdated |
||
192 | * |
||
193 | * @return PostEntity |
||
194 | */ |
||
195 | public function setTimeUpdated(\DateTime $timeUpdated) |
||
201 | |||
202 | /*** User ***/ |
||
203 | /** |
||
204 | * @return UserEntity |
||
205 | */ |
||
206 | public function getUser() |
||
210 | |||
211 | /** |
||
212 | * @param UserEntity $user |
||
213 | * |
||
214 | * @return PostEntity |
||
215 | */ |
||
216 | public function setUser(UserEntity $user = null) |
||
222 | |||
223 | /*** Post Metas ***/ |
||
224 | /** |
||
225 | * @return ArrayCollection |
||
226 | */ |
||
227 | public function getPostMetas() |
||
231 | |||
232 | /** |
||
233 | * @param ArrayCollection $postMetas |
||
234 | * |
||
235 | * @return PostEntity |
||
236 | */ |
||
237 | public function setPostMetas($postMetas) |
||
249 | |||
250 | /** |
||
251 | * @param PostMetaEntity $postMeta |
||
252 | * |
||
253 | * @return PostEntity |
||
254 | */ |
||
255 | public function addPostMeta(PostMetaEntity $postMeta) |
||
264 | |||
265 | /** |
||
266 | * @param PostMetaEntity $postMeta |
||
267 | * |
||
268 | * @return PostEntity |
||
269 | */ |
||
270 | public function removePostMeta(PostMetaEntity $postMeta) |
||
277 | |||
278 | /*** Metas ***/ |
||
279 | /** |
||
280 | * @param $key |
||
281 | * |
||
282 | * @return mixed |
||
283 | */ |
||
284 | public function getMetas($key = null) |
||
293 | |||
294 | /** |
||
295 | * @return PostEntity |
||
296 | */ |
||
297 | public function setMetas($metas) |
||
303 | |||
304 | /** |
||
305 | */ |
||
306 | public function hydratePostMetas() |
||
320 | |||
321 | /** |
||
322 | */ |
||
323 | public function convertMetasToPostMetas($uploadPath, $uploadDir) |
||
357 | |||
358 | /*** Remove image ***/ |
||
359 | /** |
||
360 | * @return bool |
||
361 | */ |
||
362 | public function getRemoveImage() |
||
366 | |||
367 | /** |
||
368 | * @param bool $removeImage |
||
369 | * |
||
370 | * @return PostEntity |
||
371 | */ |
||
372 | public function setRemoveImage($removeImage) |
||
378 | |||
379 | /** |
||
380 | * @return array |
||
381 | */ |
||
382 | public function toArray() |
||
394 | |||
395 | /** |
||
396 | * @return string |
||
397 | */ |
||
398 | public function __toString() |
||
402 | |||
403 | /** |
||
404 | * @ORM\PostLoad |
||
405 | */ |
||
406 | public function postLoad() |
||
410 | |||
411 | /** |
||
412 | * @ORM\PreUpdate |
||
413 | */ |
||
414 | public function preUpdate() |
||
418 | |||
419 | /** |
||
420 | * @ORM\PrePersist |
||
421 | */ |
||
422 | public function prePersist() |
||
427 | } |
||
428 |