Completed
Push — master ( 8f0a09...1a8186 )
by Julito
24:55
created

CForumPost::getPostText()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/* For licensing terms, see /license.txt */
4
5
namespace Chamilo\CourseBundle\Entity;
6
7
use Chamilo\CoreBundle\Entity\AbstractResource;
8
use Chamilo\CoreBundle\Entity\ResourceInterface;
9
use Doctrine\Common\Collections\ArrayCollection;
10
use Doctrine\ORM\Mapping as ORM;
11
12
/**
13
 * CForumPost.
14
 *
15
 * @ORM\Table(
16
 *  name="c_forum_post",
17
 *  indexes={
18
 *      @ORM\Index(name="course", columns={"c_id"}),
19
 *      @ORM\Index(name="poster_id", columns={"poster_id"}),
20
 *      @ORM\Index(name="forum_id", columns={"forum_id"}),
21
 *      @ORM\Index(name="idx_forum_post_thread_id", columns={"thread_id"}),
22
 *      @ORM\Index(name="idx_forum_post_visible", columns={"visible"}),
23
 *      @ORM\Index(name="c_id_visible_post_date", columns={"c_id", "visible", "post_date"})
24
 *  }
25
 * )
26
 * @ORM\Entity
27
 */
28
class CForumPost extends AbstractResource implements ResourceInterface
29
{
30
    public const STATUS_VALIDATED = 1;
31
    public const STATUS_WAITING_MODERATION = 2;
32
    public const STATUS_REJECTED = 3;
33
34
    /**
35
     * @var int
36
     *
37
     * @ORM\Column(name="iid", type="integer")
38
     * @ORM\Id
39
     * @ORM\GeneratedValue
40
     */
41
    protected $iid;
42
43
    /**
44
     * @var int
45
     *
46
     * @ORM\Column(name="c_id", type="integer")
47
     */
48
    protected $cId;
49
50
    /**
51
     * @var string
52
     *
53
     * @ORM\Column(name="post_title", type="string", length=250, nullable=true)
54
     */
55
    protected $postTitle;
56
57
    /**
58
     * @var string
59
     *
60
     * @ORM\Column(name="post_text", type="text", nullable=true)
61
     */
62
    protected $postText;
63
64
    /**
65
     * @var CForumThread|null
66
     *
67
     * @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CForumThread", inversedBy="posts")
68
     * @ORM\JoinColumn(name="thread_id", referencedColumnName="iid", nullable=true, onDelete="SET NULL")
69
     */
70
    protected $thread;
71
72
    /**
73
     * @var CForumForum|null
74
     *
75
     * @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CForumForum", inversedBy="posts")
76
     * @ORM\JoinColumn(name="forum_id", referencedColumnName="iid", nullable=true, onDelete="SET NULL")
77
     */
78
    protected $forum;
79
80
    /**
81
     * @var int
82
     *
83
     * @ORM\Column(name="poster_id", type="integer", nullable=true)
84
     */
85
    protected $posterId;
86
87
    /**
88
     * @var string
89
     *
90
     * @ORM\Column(name="poster_name", type="string", length=100, nullable=true)
91
     */
92
    protected $posterName;
93
94
    /**
95
     * @var \DateTime
96
     *
97
     * @ORM\Column(name="post_date", type="datetime", nullable=true)
98
     */
99
    protected $postDate;
100
101
    /**
102
     * @var bool
103
     *
104
     * @ORM\Column(name="post_notification", type="boolean", nullable=true)
105
     */
106
    protected $postNotification;
107
108
    /**
109
     * @var int
110
     *
111
     * @ORM\Column(name="post_parent_id", type="integer", nullable=true)
112
     */
113
    protected $postParentId;
114
115
    /**
116
     * @var bool
117
     *
118
     * @ORM\Column(name="visible", type="boolean", nullable=true)
119
     */
120
    protected $visible;
121
122
    /**
123
     * @var int
124
     *
125
     * @ORM\Column(name="status", type="integer", nullable=true)
126
     */
127
    protected $status;
128
129
    /**
130
     * @var ArrayCollection|CForumAttachment[]
131
     *
132
     * @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CForumAttachment", mappedBy="post", cascade={"persist", "remove"}, orphanRemoval=true)
133
     */
134
    protected $attachments;
135
136
    public function __construct()
137
    {
138
        $this->postParentId = null;
139
    }
140
141
    public function __toString(): string
142
    {
143
        return (string) $this->getPostTitle();
144
    }
145
146
    /**
147
     * Set postTitle.
148
     *
149
     * @param string $postTitle
150
     *
151
     * @return CForumPost
152
     */
153
    public function setPostTitle($postTitle)
154
    {
155
        $this->postTitle = $postTitle;
156
157
        return $this;
158
    }
159
160
    /**
161
     * Get postTitle.
162
     *
163
     * @return string
164
     */
165
    public function getPostTitle()
166
    {
167
        return $this->postTitle;
168
    }
169
170
    /**
171
     * Set postText.
172
     *
173
     * @param string $postText
174
     *
175
     * @return CForumPost
176
     */
177
    public function setPostText($postText)
178
    {
179
        $this->postText = $postText;
180
181
        return $this;
182
    }
183
184
    /**
185
     * Get postText.
186
     *
187
     * @return string
188
     */
189
    public function getPostText()
190
    {
191
        return $this->postText;
192
    }
193
194
    /**
195
     * Set thread.
196
     *
197
     * @return CForumPost
198
     */
199
    public function setThread(CForumThread $thread = null)
200
    {
201
        $this->thread = $thread;
202
203
        return $this;
204
    }
205
206
    /**
207
     * Get thread.
208
     *
209
     * @return CForumThread|null
210
     */
211
    public function getThread()
212
    {
213
        return $this->thread;
214
    }
215
216
    /**
217
     * Set posterId.
218
     *
219
     * @param int $posterId
220
     *
221
     * @return CForumPost
222
     */
223
    public function setPosterId($posterId)
224
    {
225
        $this->posterId = $posterId;
226
227
        return $this;
228
    }
229
230
    /**
231
     * Get posterId.
232
     *
233
     * @return int
234
     */
235
    public function getPosterId()
236
    {
237
        return $this->posterId;
238
    }
239
240
    /**
241
     * Set posterName.
242
     *
243
     * @param string $posterName
244
     *
245
     * @return CForumPost
246
     */
247
    public function setPosterName($posterName)
248
    {
249
        $this->posterName = $posterName;
250
251
        return $this;
252
    }
253
254
    /**
255
     * Get posterName.
256
     *
257
     * @return string
258
     */
259
    public function getPosterName()
260
    {
261
        return $this->posterName;
262
    }
263
264
    /**
265
     * Set postDate.
266
     *
267
     * @param \DateTime $postDate
268
     *
269
     * @return CForumPost
270
     */
271
    public function setPostDate($postDate)
272
    {
273
        $this->postDate = $postDate;
274
275
        return $this;
276
    }
277
278
    /**
279
     * Get postDate.
280
     *
281
     * @return \DateTime
282
     */
283
    public function getPostDate()
284
    {
285
        return $this->postDate;
286
    }
287
288
    /**
289
     * Set postNotification.
290
     *
291
     * @param bool $postNotification
292
     *
293
     * @return CForumPost
294
     */
295
    public function setPostNotification($postNotification)
296
    {
297
        $this->postNotification = $postNotification;
298
299
        return $this;
300
    }
301
302
    /**
303
     * Get postNotification.
304
     *
305
     * @return bool
306
     */
307
    public function getPostNotification()
308
    {
309
        return $this->postNotification;
310
    }
311
312
    /**
313
     * Set postParentId.
314
     *
315
     * @param int $postParentId
316
     *
317
     * @return CForumPost
318
     */
319
    public function setPostParentId($postParentId)
320
    {
321
        $this->postParentId = $postParentId;
322
323
        return $this;
324
    }
325
326
    /**
327
     * Get postParentId.
328
     *
329
     * @return int
330
     */
331
    public function getPostParentId()
332
    {
333
        return $this->postParentId;
334
    }
335
336
    /**
337
     * Set visible.
338
     *
339
     * @param bool $visible
340
     *
341
     * @return CForumPost
342
     */
343
    public function setVisible($visible)
344
    {
345
        $this->visible = $visible;
346
347
        return $this;
348
    }
349
350
    /**
351
     * Get visible.
352
     *
353
     * @return bool
354
     */
355
    public function getVisible()
356
    {
357
        return $this->visible;
358
    }
359
360
    /**
361
     * Set cId.
362
     *
363
     * @param int $cId
364
     *
365
     * @return CForumPost
366
     */
367
    public function setCId($cId)
368
    {
369
        $this->cId = $cId;
370
371
        return $this;
372
    }
373
374
    /**
375
     * Get cId.
376
     *
377
     * @return int
378
     */
379
    public function getCId()
380
    {
381
        return $this->cId;
382
    }
383
384
    /**
385
     * @return int
386
     */
387
    public function getStatus()
388
    {
389
        return $this->status;
390
    }
391
392
    /**
393
     * @param int $status
394
     *
395
     * @return CForumPost
396
     */
397
    public function setStatus($status)
398
    {
399
        $this->status = $status;
400
401
        return $this;
402
    }
403
404
    /**
405
     * Get iid.
406
     *
407
     * @return int
408
     */
409
    public function getIid()
410
    {
411
        return $this->iid;
412
    }
413
414
    /**
415
     * @return CForumAttachment[]
416
     */
417
    public function getAttachments()
418
    {
419
        return $this->attachments;
420
    }
421
422
    public function removeAttachment(CForumAttachment $attachment)
423
    {
424
        $this->attachments->removeElement($attachment);
425
    }
426
427
    public function getForum(): ?CForumForum
428
    {
429
        return $this->forum;
430
    }
431
432
    public function setForum(?CForumForum $forum): self
433
    {
434
        $this->forum = $forum;
435
436
        return $this;
437
    }
438
439
    /**
440
     * Resource identifier.
441
     */
442
    public function getResourceIdentifier(): int
443
    {
444
        return $this->getIid();
445
    }
446
447
    public function getResourceName(): string
448
    {
449
        return $this->getPostTitle();
450
    }
451
452
    public function setResourceName(string $name): self
453
    {
454
        return $this->setPostTitle($name);
455
    }
456
}
457