Passed
Push — master ( 8dc8d6...0b0f56 )
by Julito
10:41
created

CForumPost::setPosterName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
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 Chamilo\CoreBundle\Entity\User;
10
use Doctrine\Common\Collections\ArrayCollection;
11
use Doctrine\ORM\Mapping as ORM;
12
13
/**
14
 * CForumPost.
15
 *
16
 * @ORM\Table(
17
 *  name="c_forum_post",
18
 *  indexes={
19
 *      @ORM\Index(name="course", columns={"c_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
     * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\User")
82
     * @ORM\JoinColumn(name="poster_id", referencedColumnName="id")
83
     */
84
    protected $user;
85
86
    /**
87
     * @var \DateTime
88
     *
89
     * @ORM\Column(name="post_date", type="datetime", nullable=true)
90
     */
91
    protected $postDate;
92
93
    /**
94
     * @var bool
95
     *
96
     * @ORM\Column(name="post_notification", type="boolean", nullable=true)
97
     */
98
    protected $postNotification;
99
100
    /**
101
     * @var int
102
     *
103
     * @ORM\Column(name="post_parent_id", type="integer", nullable=true)
104
     */
105
    protected $postParentId;
106
107
    /**
108
     * @var bool
109
     *
110
     * @ORM\Column(name="visible", type="boolean", nullable=true)
111
     */
112
    protected $visible;
113
114
    /**
115
     * @var int
116
     *
117
     * @ORM\Column(name="status", type="integer", nullable=true)
118
     */
119
    protected $status;
120
121
    /**
122
     * @var ArrayCollection|CForumAttachment[]
123
     *
124
     * @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CForumAttachment", mappedBy="post", cascade={"persist", "remove"}, orphanRemoval=true)
125
     */
126
    protected $attachments;
127
128
    public function __construct()
129
    {
130
        $this->postParentId = null;
131
        $this->attachments = new ArrayCollection();
132
    }
133
134
    public function __toString(): string
135
    {
136
        return (string) $this->getPostTitle();
137
    }
138
139
    /**
140
     * Set postTitle.
141
     *
142
     * @param string $postTitle
143
     *
144
     * @return CForumPost
145
     */
146
    public function setPostTitle($postTitle)
147
    {
148
        $this->postTitle = $postTitle;
149
150
        return $this;
151
    }
152
153
    /**
154
     * Get postTitle.
155
     *
156
     * @return string
157
     */
158
    public function getPostTitle()
159
    {
160
        return $this->postTitle;
161
    }
162
163
    /**
164
     * Set postText.
165
     *
166
     * @param string $postText
167
     *
168
     * @return CForumPost
169
     */
170
    public function setPostText($postText)
171
    {
172
        $this->postText = $postText;
173
174
        return $this;
175
    }
176
177
    /**
178
     * Get postText.
179
     *
180
     * @return string
181
     */
182
    public function getPostText()
183
    {
184
        return $this->postText;
185
    }
186
187
    /**
188
     * Set thread.
189
     *
190
     * @return CForumPost
191
     */
192
    public function setThread(CForumThread $thread = null)
193
    {
194
        $this->thread = $thread;
195
196
        return $this;
197
    }
198
199
    /**
200
     * Get thread.
201
     *
202
     * @return CForumThread|null
203
     */
204
    public function getThread()
205
    {
206
        return $this->thread;
207
    }
208
209
    /**
210
     * Set postDate.
211
     *
212
     * @param \DateTime $postDate
213
     *
214
     * @return CForumPost
215
     */
216
    public function setPostDate($postDate)
217
    {
218
        $this->postDate = $postDate;
219
220
        return $this;
221
    }
222
223
    /**
224
     * Get postDate.
225
     *
226
     * @return \DateTime
227
     */
228
    public function getPostDate()
229
    {
230
        return $this->postDate;
231
    }
232
233
    /**
234
     * Set postNotification.
235
     *
236
     * @param bool $postNotification
237
     *
238
     * @return CForumPost
239
     */
240
    public function setPostNotification($postNotification)
241
    {
242
        $this->postNotification = $postNotification;
243
244
        return $this;
245
    }
246
247
    /**
248
     * Get postNotification.
249
     *
250
     * @return bool
251
     */
252
    public function getPostNotification()
253
    {
254
        return $this->postNotification;
255
    }
256
257
    /**
258
     * Set postParentId.
259
     *
260
     * @param int $postParentId
261
     *
262
     * @return CForumPost
263
     */
264
    public function setPostParentId($postParentId)
265
    {
266
        $this->postParentId = $postParentId;
267
268
        return $this;
269
    }
270
271
    /**
272
     * Get postParentId.
273
     *
274
     * @return int
275
     */
276
    public function getPostParentId()
277
    {
278
        return $this->postParentId;
279
    }
280
281
    /**
282
     * Set visible.
283
     *
284
     * @param bool $visible
285
     *
286
     * @return CForumPost
287
     */
288
    public function setVisible($visible)
289
    {
290
        $this->visible = $visible;
291
292
        return $this;
293
    }
294
295
    /**
296
     * Get visible.
297
     *
298
     * @return bool
299
     */
300
    public function getVisible()
301
    {
302
        return $this->visible;
303
    }
304
305
    /**
306
     * Set cId.
307
     *
308
     * @param int $cId
309
     *
310
     * @return CForumPost
311
     */
312
    public function setCId($cId)
313
    {
314
        $this->cId = $cId;
315
316
        return $this;
317
    }
318
319
    /**
320
     * Get cId.
321
     *
322
     * @return int
323
     */
324
    public function getCId()
325
    {
326
        return $this->cId;
327
    }
328
329
    /**
330
     * @return int
331
     */
332
    public function getStatus()
333
    {
334
        return $this->status;
335
    }
336
337
    /**
338
     * @param int $status
339
     *
340
     * @return CForumPost
341
     */
342
    public function setStatus($status)
343
    {
344
        $this->status = $status;
345
346
        return $this;
347
    }
348
349
    /**
350
     * Get iid.
351
     *
352
     * @return int
353
     */
354
    public function getIid()
355
    {
356
        return $this->iid;
357
    }
358
359
    /**
360
     * @return CForumAttachment[]
361
     */
362
    public function getAttachments()
363
    {
364
        return $this->attachments;
365
    }
366
367
    public function removeAttachment(CForumAttachment $attachment)
368
    {
369
        $this->attachments->removeElement($attachment);
370
    }
371
372
    public function getForum(): ?CForumForum
373
    {
374
        return $this->forum;
375
    }
376
377
    public function setForum(?CForumForum $forum): self
378
    {
379
        $this->forum = $forum;
380
381
        return $this;
382
    }
383
384
    /**
385
     * @return mixed
386
     */
387
    public function getUser()
388
    {
389
        return $this->user;
390
    }
391
392
    public function setUser(User $user): self
393
    {
394
        $this->user = $user;
395
396
        return $this;
397
    }
398
399
    public function getResourceIdentifier(): int
400
    {
401
        return $this->getIid();
402
    }
403
404
    public function getResourceName(): string
405
    {
406
        return $this->getPostTitle();
407
    }
408
409
    public function setResourceName(string $name): self
410
    {
411
        return $this->setPostTitle($name);
412
    }
413
}
414