Passed
Push — master ( 8d1a37...25babe )
by Julito
22:45
created

CForumThread::getResourceIdentifier()   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
declare(strict_types=1);
4
5
/* For licensing terms, see /license.txt */
6
7
namespace Chamilo\CourseBundle\Entity;
8
9
use Chamilo\CoreBundle\Entity\AbstractResource;
10
use Chamilo\CoreBundle\Entity\ResourceInterface;
11
use Chamilo\CoreBundle\Entity\User;
12
use DateTime;
13
use Doctrine\Common\Collections\ArrayCollection;
14
use Doctrine\Common\Collections\Collection;
15
use Doctrine\ORM\Mapping as ORM;
16
use Symfony\Component\Validator\Constraints as Assert;
17
18
/**
19
 * CForumThread.
20
 *
21
 * @ORM\Table(
22
 *     name="c_forum_thread",
23
 *     indexes={
24
 *     }
25
 * )
26
 * @ORM\Entity
27
 */
28
class CForumThread extends AbstractResource implements ResourceInterface
29
{
30
    /**
31
     * @ORM\Column(name="iid", type="integer")
32
     * @ORM\Id
33
     * @ORM\GeneratedValue
34
     */
35
    protected int $iid;
36
37
    /**
38
     * @Assert\NotBlank()
39
     *
40
     * @ORM\Column(name="thread_title", type="string", length=255, nullable=false)
41
     */
42
    protected string $threadTitle;
43
44
    /**
45
     * @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CForumForum", inversedBy="threads")
46
     * @ORM\JoinColumn(name="forum_id", referencedColumnName="iid", nullable=true, onDelete="SET NULL")
47
     */
48
    protected ?CForumForum $forum = null;
49
50
    /**
51
     * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\User")
52
     * @ORM\JoinColumn(name="thread_poster_id", referencedColumnName="id")
53
     */
54
    protected User $user;
55
56
    /**
57
     * @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CForumPost", cascade={"persist", "remove"})
58
     * @ORM\JoinColumn(name="thread_last_post", referencedColumnName="iid", onDelete="SET NULL")
59
     */
60
    protected ?CForumPost $threadLastPost = null;
61
62
    /**
63
     * @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CLpItem")
64
     * @ORM\JoinColumn(name="lp_item_id", referencedColumnName="iid", onDelete="CASCADE")
65
     */
66
    protected ?CLpItem $item = null;
67
68
    /**
69
     * @var Collection|CForumPost[]
70
     *
71
     * @ORM\OneToMany(targetEntity="CForumPost", mappedBy="thread", cascade={"persist", "remove"}, orphanRemoval=true)
72
     */
73
    protected Collection $posts;
74
75
    /**
76
     * @var Collection|CForumThreadQualify[]
77
     *
78
     * @ORM\OneToMany(targetEntity="CForumThreadQualify", mappedBy="thread", cascade={"persist", "remove"})
79
     */
80
    protected Collection $qualifications;
81
82
    /**
83
     * @ORM\Column(name="thread_date", type="datetime", nullable=false)
84
     */
85
    protected DateTime $threadDate;
86
87
    /**
88
     * @ORM\Column(name="thread_replies", type="integer", nullable=false, options={"unsigned":true, "default":0})
89
     */
90
    protected int $threadReplies;
91
92
    /**
93
     * @ORM\Column(name="thread_views", type="integer", nullable=false, options={"unsigned":true, "default":0})
94
     */
95
    protected int $threadViews;
96
97
    /**
98
     * @ORM\Column(name="thread_sticky", type="boolean", nullable=false)
99
     */
100
    protected bool $threadSticky;
101
102
    /**
103
     * @ORM\Column(name="locked", type="integer", nullable=false)
104
     */
105
    protected int $locked;
106
107
    /**
108
     * @ORM\Column(name="thread_title_qualify", type="string", length=255, nullable=true)
109
     */
110
    protected ?string $threadTitleQualify = null;
111
112
    /**
113
     * @ORM\Column(name="thread_qualify_max", type="float", precision=6, scale=2, nullable=false)
114
     */
115
    protected float $threadQualifyMax;
116
117
    /**
118
     * @ORM\Column(name="thread_close_date", type="datetime", nullable=true)
119
     */
120
    protected ?DateTime $threadCloseDate = null;
121
122
    /**
123
     * @ORM\Column(name="thread_weight", type="float", precision=6, scale=2, nullable=false)
124
     */
125
    protected float $threadWeight;
126
127
    /**
128
     * @ORM\Column(name="thread_peer_qualify", type="boolean")
129
     */
130
    protected bool $threadPeerQualify;
131
132
    public function __construct()
133
    {
134
        $this->posts = new ArrayCollection();
135
        $this->qualifications = new ArrayCollection();
136
        $this->threadPeerQualify = false;
137
        $this->threadReplies = 0;
138
        $this->threadViews = 0;
139
        $this->locked = 0;
140
        $this->threadQualifyMax = 0;
141
        $this->threadWeight = 0;
142
        $this->threadSticky = false;
143
    }
144
145
    public function __toString(): string
146
    {
147
        return (string) $this->getThreadTitle();
148
    }
149
150
    public function isThreadPeerQualify(): bool
151
    {
152
        return $this->threadPeerQualify;
153
    }
154
155
    /**
156
     * set threadPeerQualify.
157
     *
158
     * @return $this
159
     */
160
    public function setThreadPeerQualify(bool $threadPeerQualify): self
161
    {
162
        $this->threadPeerQualify = $threadPeerQualify;
163
164
        return $this;
165
    }
166
167
    public function setThreadTitle(string $threadTitle): self
168
    {
169
        $this->threadTitle = $threadTitle;
170
171
        return $this;
172
    }
173
174
    /**
175
     * Get threadTitle.
176
     *
177
     * @return string
178
     */
179
    public function getThreadTitle()
180
    {
181
        return $this->threadTitle;
182
    }
183
184
    public function setForum(CForumForum $forum = null): self
185
    {
186
        $this->forum = $forum;
187
188
        return $this;
189
    }
190
191
    /**
192
     * Get forumId.
193
     *
194
     * @return null|CForumForum
195
     */
196
    public function getForum()
197
    {
198
        return $this->forum;
199
    }
200
201
    /**
202
     * Set threadReplies.
203
     *
204
     * @return CForumThread
205
     */
206
    public function setThreadReplies(int $threadReplies): self
207
    {
208
        $this->threadReplies = $threadReplies;
209
210
        return $this;
211
    }
212
213
    /**
214
     * Get threadReplies.
215
     *
216
     * @return int
217
     */
218
    public function getThreadReplies()
219
    {
220
        return $this->threadReplies;
221
    }
222
223
    public function setThreadViews(int $threadViews): self
224
    {
225
        $this->threadViews = $threadViews;
226
227
        return $this;
228
    }
229
230
    /**
231
     * Get threadViews.
232
     *
233
     * @return int
234
     */
235
    public function getThreadViews()
236
    {
237
        return $this->threadViews;
238
    }
239
240
    public function setThreadDate(DateTime $threadDate): self
241
    {
242
        $this->threadDate = $threadDate;
243
244
        return $this;
245
    }
246
247
    /**
248
     * Get threadDate.
249
     *
250
     * @return DateTime
251
     */
252
    public function getThreadDate()
253
    {
254
        return $this->threadDate;
255
    }
256
257
    public function setThreadSticky(bool $threadSticky): self
258
    {
259
        $this->threadSticky = $threadSticky;
260
261
        return $this;
262
    }
263
264
    /**
265
     * Get threadSticky.
266
     *
267
     * @return bool
268
     */
269
    public function getThreadSticky()
270
    {
271
        return $this->threadSticky;
272
    }
273
274
    public function setLocked(int $locked): self
275
    {
276
        $this->locked = $locked;
277
278
        return $this;
279
    }
280
281
    /**
282
     * Get locked.
283
     *
284
     * @return int
285
     */
286
    public function getLocked()
287
    {
288
        return $this->locked;
289
    }
290
291
    public function setThreadTitleQualify(string $threadTitleQualify): self
292
    {
293
        $this->threadTitleQualify = $threadTitleQualify;
294
295
        return $this;
296
    }
297
298
    /**
299
     * Get threadTitleQualify.
300
     *
301
     * @return string
302
     */
303
    public function getThreadTitleQualify()
304
    {
305
        return $this->threadTitleQualify;
306
    }
307
308
    public function setThreadQualifyMax(float $threadQualifyMax): self
309
    {
310
        $this->threadQualifyMax = $threadQualifyMax;
311
312
        return $this;
313
    }
314
315
    /**
316
     * Get threadQualifyMax.
317
     *
318
     * @return float
319
     */
320
    public function getThreadQualifyMax()
321
    {
322
        return $this->threadQualifyMax;
323
    }
324
325
    public function setThreadCloseDate(DateTime $threadCloseDate): self
326
    {
327
        $this->threadCloseDate = $threadCloseDate;
328
329
        return $this;
330
    }
331
332
    /**
333
     * Get threadCloseDate.
334
     *
335
     * @return DateTime
336
     */
337
    public function getThreadCloseDate()
338
    {
339
        return $this->threadCloseDate;
340
    }
341
342
    /**
343
     * Set threadWeight.
344
     *
345
     * @return CForumThread
346
     */
347
    public function setThreadWeight(float $threadWeight): self
348
    {
349
        $this->threadWeight = $threadWeight;
350
351
        return $this;
352
    }
353
354
    /**
355
     * Get threadWeight.
356
     *
357
     * @return float
358
     */
359
    public function getThreadWeight()
360
    {
361
        return $this->threadWeight;
362
    }
363
364
    /**
365
     * Get iid.
366
     *
367
     * @return int
368
     */
369
    public function getIid()
370
    {
371
        return $this->iid;
372
    }
373
374
    public function getUser(): User
375
    {
376
        return $this->user;
377
    }
378
379
    public function setUser(User $user): self
380
    {
381
        $this->user = $user;
382
383
        return $this;
384
    }
385
386
    /**
387
     * @return Collection|CForumPost[]
388
     */
389
    public function getPosts()
390
    {
391
        return $this->posts;
392
    }
393
394
    public function getThreadLastPost(): ?CForumPost
395
    {
396
        return $this->threadLastPost;
397
    }
398
399
    public function setThreadLastPost(CForumPost $threadLastPost): self
400
    {
401
        $this->threadLastPost = $threadLastPost;
402
403
        return $this;
404
    }
405
406
    /**
407
     * @return CForumThreadQualify[]|Collection
408
     */
409
    public function getQualifications()
410
    {
411
        return $this->qualifications;
412
    }
413
414
    /**
415
     * @param CForumThreadQualify[]|Collection $qualifications
416
     */
417
    public function setQualifications(Collection $qualifications): self
418
    {
419
        $this->qualifications = $qualifications;
420
421
        return $this;
422
    }
423
424
    public function getItem(): ?CLpItem
425
    {
426
        return $this->item;
427
    }
428
429
    public function setItem(?CLpItem $item): self
430
    {
431
        $this->item = $item;
432
433
        return $this;
434
    }
435
436
    public function getResourceIdentifier(): int
437
    {
438
        return $this->getIid();
439
    }
440
441
    public function getResourceName(): string
442
    {
443
        return $this->getThreadTitle();
444
    }
445
446
    public function setResourceName(string $name): self
447
    {
448
        return $this->setThreadTitle($name);
449
    }
450
}
451