Passed
Push — master ( a5a3c9...cc0a46 )
by Julito
17:31
created

CForum::setForumLastPost()   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
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 10
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 DateTime;
12
use Doctrine\Common\Collections\ArrayCollection;
13
use Doctrine\Common\Collections\Collection;
14
use Doctrine\ORM\Mapping as ORM;
15
use Gedmo\Mapping\Annotation as Gedmo;
16
use Symfony\Component\Validator\Constraints as Assert;
17
18
/**
19
 * Course forums.
20
 *
21
 * @ORM\Table(
22
 *     name="c_forum_forum",
23
 *     indexes={
24
 *     }
25
 * )
26
 * @ORM\Entity
27
 */
28
class CForum 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="forum_title", type="string", length=255, nullable=false)
41
     */
42
    protected string $forumTitle;
43
44
    /**
45
     * @ORM\Column(name="forum_comment", type="text", nullable=true)
46
     */
47
    protected ?string $forumComment;
48
49
    /**
50
     * @ORM\Column(name="forum_threads", type="integer", nullable=true)
51
     */
52
    protected ?int $forumThreads = null;
53
54
    /**
55
     * @ORM\Column(name="forum_posts", type="integer", nullable=true)
56
     */
57
    protected ?int $forumPosts;
58
59
    /**
60
     * @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CForumPost")
61
     * @ORM\JoinColumn(name="forum_last_post", referencedColumnName="iid")
62
     */
63
    protected ?CForumPost $forumLastPost = null;
64
65
    /**
66
     * @Gedmo\SortableGroup
67
     *
68
     * @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CForumCategory", inversedBy="forums")
69
     * @ORM\JoinColumn(name="forum_category", referencedColumnName="iid", nullable=true, onDelete="SET NULL")
70
     */
71
    protected ?CForumCategory $forumCategory = null;
72
73
    /**
74
     * @ORM\Column(name="allow_anonymous", type="integer", nullable=true)
75
     */
76
    protected ?int $allowAnonymous = null;
77
78
    /**
79
     * @ORM\Column(name="allow_edit", type="integer", nullable=true)
80
     */
81
    protected ?int $allowEdit = null;
82
83
    /**
84
     * @ORM\Column(name="approval_direct_post", type="string", length=20, nullable=true)
85
     */
86
    protected ?string $approvalDirectPost = null;
87
88
    /**
89
     * @ORM\Column(name="allow_attachments", type="integer", nullable=true)
90
     */
91
    protected ?int $allowAttachments = null;
92
93
    /**
94
     * @ORM\Column(name="allow_new_threads", type="integer", nullable=true)
95
     */
96
    protected ?int $allowNewThreads = null;
97
98
    /**
99
     * @ORM\Column(name="default_view", type="string", length=20, nullable=true)
100
     */
101
    protected ?string $defaultView = null;
102
103
    /**
104
     * @ORM\Column(name="forum_of_group", type="string", length=20, nullable=true)
105
     */
106
    protected ?string $forumOfGroup;
107
108
    /**
109
     * @ORM\Column(name="forum_group_public_private", type="string", length=20, nullable=true)
110
     */
111
    protected ?string $forumGroupPublicPrivate;
112
113
    /**
114
     * @Gedmo\SortablePosition
115
     *
116
     * @ORM\Column(name="forum_order", type="integer", nullable=true)
117
     */
118
    protected ?int $forumOrder = null;
119
120
    /**
121
     * @ORM\Column(name="locked", type="integer", nullable=false)
122
     */
123
    protected int $locked;
124
125
    /**
126
     * @ORM\Column(name="session_id", type="integer", nullable=false)
127
     */
128
    protected int $sessionId;
129
130
    /**
131
     * @ORM\Column(name="forum_image", type="string", length=255, nullable=false)
132
     */
133
    protected string $forumImage;
134
135
    /**
136
     * @ORM\Column(name="start_time", type="datetime", nullable=true)
137
     */
138
    protected ?DateTime $startTime = null;
139
140
    /**
141
     * @ORM\Column(name="end_time", type="datetime", nullable=true)
142
     */
143
    protected ?DateTime $endTime = null;
144
145
    /**
146
     * @ORM\OneToOne(targetEntity="Chamilo\CourseBundle\Entity\CLp", inversedBy="forum")
147
     * @ORM\JoinColumn(name="lp_id", referencedColumnName="iid", nullable=true)
148
     */
149
    protected ?CLp $lp = null;
150
151
    /**
152
     * @ORM\Column(name="moderated", type="boolean", nullable=true)
153
     */
154
    protected ?bool $moderated = null;
155
156
    /**
157
     * @var Collection|CForumThread[]
158
     *
159
     * @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CForumThread", mappedBy="forum")
160
     */
161
    protected Collection $threads;
162
163
    /**
164
     * @var Collection|CForumPost[]
165
     *
166
     * @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CForumPost", mappedBy="forum")
167
     */
168
    protected Collection $posts;
169
170
    public function __construct()
171
    {
172
        $this->threads = new ArrayCollection();
173
        $this->posts = new ArrayCollection();
174
        $this->locked = 0;
175
        $this->forumComment = '';
176
        $this->forumImage = '';
177
        $this->forumOfGroup = '';
178
        $this->forumPosts = 0;
179
        $this->forumGroupPublicPrivate = '';
180
    }
181
182
    public function __toString(): string
183
    {
184
        return $this->getForumTitle();
185
    }
186
187
    public function setForumTitle(string $forumTitle): self
188
    {
189
        $this->forumTitle = $forumTitle;
190
191
        return $this;
192
    }
193
194
    public function getForumTitle(): string
195
    {
196
        return $this->forumTitle;
197
    }
198
199
    public function setForumComment(string $forumComment): self
200
    {
201
        $this->forumComment = $forumComment;
202
203
        return $this;
204
    }
205
206
    public function getForumComment(): string
207
    {
208
        return $this->forumComment;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->forumComment could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
209
    }
210
211
    public function setForumThreads(int $forumThreads): self
212
    {
213
        $this->forumThreads = $forumThreads;
214
215
        return $this;
216
    }
217
218
    /**
219
     * Get forumThreads.
220
     *
221
     * @return int
222
     */
223
    public function getForumThreads()
224
    {
225
        return $this->forumThreads;
226
    }
227
228
    public function hasThread(CForumThread $thread): bool
229
    {
230
        return $this->threads->contains($thread);
231
    }
232
233
    public function setForumPosts(int $forumPosts): self
234
    {
235
        $this->forumPosts = $forumPosts;
236
237
        return $this;
238
    }
239
240
    /**
241
     * Get forumPosts.
242
     *
243
     * @return int
244
     */
245
    public function getForumPosts()
246
    {
247
        return $this->forumPosts;
248
    }
249
250
    public function setForumCategory(CForumCategory $forumCategory = null): self
251
    {
252
        $this->forumCategory = $forumCategory;
253
254
        return $this;
255
    }
256
257
    /**
258
     * Get forumCategory.
259
     *
260
     * @return null|CForumCategory
261
     */
262
    public function getForumCategory()
263
    {
264
        return $this->forumCategory;
265
    }
266
267
    public function setAllowAnonymous(int $allowAnonymous): self
268
    {
269
        $this->allowAnonymous = $allowAnonymous;
270
271
        return $this;
272
    }
273
274
    /**
275
     * Get allowAnonymous.
276
     *
277
     * @return int
278
     */
279
    public function getAllowAnonymous()
280
    {
281
        return $this->allowAnonymous;
282
    }
283
284
    public function setAllowEdit(int $allowEdit): self
285
    {
286
        $this->allowEdit = $allowEdit;
287
288
        return $this;
289
    }
290
291
    /**
292
     * Get allowEdit.
293
     *
294
     * @return int
295
     */
296
    public function getAllowEdit()
297
    {
298
        return $this->allowEdit;
299
    }
300
301
    public function setApprovalDirectPost(string $approvalDirectPost): self
302
    {
303
        $this->approvalDirectPost = $approvalDirectPost;
304
305
        return $this;
306
    }
307
308
    /**
309
     * Get approvalDirectPost.
310
     *
311
     * @return string
312
     */
313
    public function getApprovalDirectPost()
314
    {
315
        return $this->approvalDirectPost;
316
    }
317
318
    public function setAllowAttachments(int $allowAttachments): self
319
    {
320
        $this->allowAttachments = $allowAttachments;
321
322
        return $this;
323
    }
324
325
    /**
326
     * Get allowAttachments.
327
     *
328
     * @return int
329
     */
330
    public function getAllowAttachments()
331
    {
332
        return $this->allowAttachments;
333
    }
334
335
    public function setAllowNewThreads(int $allowNewThreads): self
336
    {
337
        $this->allowNewThreads = $allowNewThreads;
338
339
        return $this;
340
    }
341
342
    /**
343
     * Get allowNewThreads.
344
     *
345
     * @return int
346
     */
347
    public function getAllowNewThreads()
348
    {
349
        return $this->allowNewThreads;
350
    }
351
352
    public function setDefaultView(string $defaultView): self
353
    {
354
        $this->defaultView = $defaultView;
355
356
        return $this;
357
    }
358
359
    /**
360
     * Get defaultView.
361
     *
362
     * @return string
363
     */
364
    public function getDefaultView()
365
    {
366
        return $this->defaultView;
367
    }
368
369
    public function setForumOfGroup(string $forumOfGroup): self
370
    {
371
        $this->forumOfGroup = $forumOfGroup;
372
373
        return $this;
374
    }
375
376
    /**
377
     * Get forumOfGroup.
378
     *
379
     * @return string
380
     */
381
    public function getForumOfGroup()
382
    {
383
        return $this->forumOfGroup;
384
    }
385
386
    public function getForumGroupPublicPrivate(): string
387
    {
388
        return $this->forumGroupPublicPrivate;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->forumGroupPublicPrivate could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
389
    }
390
391
    /**
392
     * @return $this
393
     */
394
    public function setForumGroupPublicPrivate(string $forumGroupPublicPrivate)
395
    {
396
        $this->forumGroupPublicPrivate = $forumGroupPublicPrivate;
397
398
        return $this;
399
    }
400
401
    public function setForumOrder(int $forumOrder): self
402
    {
403
        $this->forumOrder = $forumOrder;
404
405
        return $this;
406
    }
407
408
    /**
409
     * Get forumOrder.
410
     *
411
     * @return int
412
     */
413
    public function getForumOrder()
414
    {
415
        return $this->forumOrder;
416
    }
417
418
    public function setLocked(int $locked): self
419
    {
420
        $this->locked = $locked;
421
422
        return $this;
423
    }
424
425
    /**
426
     * Get locked.
427
     *
428
     * @return int
429
     */
430
    public function getLocked()
431
    {
432
        return $this->locked;
433
    }
434
435
    public function setSessionId(int $sessionId): self
436
    {
437
        $this->sessionId = $sessionId;
438
439
        return $this;
440
    }
441
442
    /**
443
     * Get sessionId.
444
     *
445
     * @return int
446
     */
447
    public function getSessionId()
448
    {
449
        return $this->sessionId;
450
    }
451
452
    public function setForumImage(string $forumImage): self
453
    {
454
        $this->forumImage = $forumImage;
455
456
        return $this;
457
    }
458
459
    /**
460
     * Get forumImage.
461
     *
462
     * @return string
463
     */
464
    public function getForumImage()
465
    {
466
        return $this->forumImage;
467
    }
468
469
    public function setStartTime(?DateTime $startTime): self
470
    {
471
        $this->startTime = $startTime;
472
473
        return $this;
474
    }
475
476
    /**
477
     * Get startTime.
478
     *
479
     * @return DateTime
480
     */
481
    public function getStartTime()
482
    {
483
        return $this->startTime;
484
    }
485
486
    public function setEndTime(?DateTime $endTime): self
487
    {
488
        $this->endTime = $endTime;
489
490
        return $this;
491
    }
492
493
    /**
494
     * Get endTime.
495
     *
496
     * @return DateTime
497
     */
498
    public function getEndTime()
499
    {
500
        return $this->endTime;
501
    }
502
503
    public function isModerated(): bool
504
    {
505
        return $this->moderated;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->moderated could return the type null which is incompatible with the type-hinted return boolean. Consider adding an additional type-check to rule them out.
Loading history...
506
    }
507
508
    public function setModerated(bool $moderated): self
509
    {
510
        $this->moderated = $moderated;
511
512
        return $this;
513
    }
514
515
    /**
516
     * Get iid.
517
     *
518
     * @return int
519
     */
520
    public function getIid()
521
    {
522
        return $this->iid;
523
    }
524
525
    /**
526
     * Get threads.
527
     *
528
     * @return Collection|CForumThread[]
529
     */
530
    public function getThreads()
531
    {
532
        return $this->threads;
533
    }
534
535
    public function getForumLastPost(): ?CForumPost
536
    {
537
        return $this->forumLastPost;
538
    }
539
540
    public function setForumLastPost(CForumPost $forumLastPost): self
541
    {
542
        $this->forumLastPost = $forumLastPost;
543
544
        return $this;
545
    }
546
547
    public function getLp(): ?CLp
548
    {
549
        return $this->lp;
550
    }
551
552
    public function setLp(?CLp $lp): self
553
    {
554
        $this->lp = $lp;
555
556
        return $this;
557
    }
558
559
    /**
560
     * @return Collection|CForumPost[]
561
     */
562
    public function getPosts()
563
    {
564
        return $this->posts;
565
    }
566
567
    public function getResourceIdentifier(): int
568
    {
569
        return $this->getIid();
570
    }
571
572
    public function getResourceName(): string
573
    {
574
        return $this->getForumTitle();
575
    }
576
577
    public function setResourceName(string $name): self
578
    {
579
        return $this->setForumTitle($name);
580
    }
581
}
582