Passed
Push — master ( eb5904...054905 )
by Angel Fernando Quiroz
08:23
created

CLp::setTitle()   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
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\Asset;
11
use Chamilo\CoreBundle\Entity\ResourceInterface;
12
use Chamilo\CoreBundle\Entity\ResourceShowCourseResourcesInSessionInterface;
13
use Chamilo\CourseBundle\Repository\CLpRepository;
14
use DateTime;
15
use Doctrine\Common\Collections\ArrayCollection;
16
use Doctrine\Common\Collections\Collection;
17
use Doctrine\ORM\Mapping as ORM;
18
use Gedmo\Mapping\Annotation as Gedmo;
19
use Stringable;
20
use Symfony\Component\Uid\Uuid;
21
use Symfony\Component\Validator\Constraints as Assert;
22
23
/**
24
 * Course learning paths (LPs).
25
 */
26
#[ORM\Table(name: 'c_lp')]
27
#[ORM\Entity(repositoryClass: CLpRepository::class)]
28
class CLp extends AbstractResource implements ResourceInterface, ResourceShowCourseResourcesInSessionInterface, Stringable
29
{
30
    public const LP_TYPE = 1;
31
    public const SCORM_TYPE = 2;
32
    public const AICC_TYPE = 3;
33
34
    #[ORM\Column(name: 'iid', type: 'integer')]
35
    #[ORM\Id]
36
    #[ORM\GeneratedValue]
37
    protected ?int $iid = null;
38
39
    #[Assert\NotBlank]
40
    #[ORM\Column(name: 'lp_type', type: 'integer', nullable: false)]
41
    protected int $lpType;
42
43
    #[Assert\NotBlank]
44
    #[ORM\Column(name: 'title', type: 'string', length: 255, nullable: false)]
45
    protected string $title;
46
47
    #[ORM\Column(name: 'ref', type: 'text', nullable: true)]
48
    protected ?string $ref = null;
49
50
    #[ORM\Column(name: 'description', type: 'text', nullable: true)]
51
    protected ?string $description;
52
53
    #[ORM\Column(name: 'path', type: 'text', nullable: false)]
54
    protected string $path;
55
56
    #[ORM\Column(name: 'force_commit', type: 'boolean', nullable: false)]
57
    protected bool $forceCommit;
58
59
    #[ORM\Column(name: 'default_view_mod', type: 'string', length: 32, nullable: false, options: ['default' => 'embedded'])]
60
    protected string $defaultViewMod;
61
62
    #[ORM\Column(name: 'default_encoding', type: 'string', length: 32, nullable: false, options: ['default' => 'UTF-8'])]
63
    protected string $defaultEncoding;
64
65
    #[ORM\Column(name: 'content_maker', type: 'text', nullable: false)]
66
    protected string $contentMaker;
67
68
    #[ORM\Column(name: 'content_local', type: 'string', length: 32, nullable: false, options: ['default' => 'local'])]
69
    protected string $contentLocal;
70
71
    #[ORM\Column(name: 'content_license', type: 'text', nullable: false)]
72
    protected string $contentLicense;
73
74
    #[ORM\Column(name: 'prevent_reinit', type: 'boolean', nullable: false, options: ['default' => 1])]
75
    protected bool $preventReinit;
76
77
    #[ORM\Column(name: 'js_lib', type: 'text', nullable: false)]
78
    protected string $jsLib;
79
80
    #[ORM\Column(name: 'debug', type: 'boolean', nullable: false)]
81
    protected bool $debug;
82
83
    #[Assert\NotBlank]
84
    #[ORM\Column(name: 'theme', type: 'string', length: 255, nullable: false)]
85
    protected string $theme;
86
87
    #[Assert\NotBlank]
88
    #[ORM\Column(name: 'author', type: 'text', nullable: false)]
89
    protected string $author;
90
91
    #[ORM\Column(name: 'prerequisite', type: 'integer', nullable: false)]
92
    protected int $prerequisite;
93
94
    #[ORM\Column(name: 'hide_toc_frame', type: 'boolean', nullable: false)]
95
    protected bool $hideTocFrame;
96
97
    #[ORM\Column(name: 'seriousgame_mode', type: 'boolean', nullable: false)]
98
    protected bool $seriousgameMode;
99
100
    #[ORM\Column(name: 'use_max_score', type: 'integer', nullable: false, options: ['default' => 1])]
101
    protected int $useMaxScore;
102
103
    #[ORM\Column(name: 'autolaunch', type: 'integer', nullable: false)]
104
    protected int $autolaunch;
105
106
    #[ORM\ManyToOne(targetEntity: CLpCategory::class, inversedBy: 'lps')]
107
    #[ORM\JoinColumn(name: 'category_id', referencedColumnName: 'iid')]
108
    protected ?CLpCategory $category = null;
109
110
    #[ORM\Column(name: 'max_attempts', type: 'integer', nullable: false)]
111
    protected int $maxAttempts;
112
113
    #[ORM\Column(name: 'subscribe_users', type: 'integer', nullable: false)]
114
    protected int $subscribeUsers;
115
116
    #[Gedmo\Timestampable(on: 'create')]
117
    #[ORM\Column(name: 'created_on', type: 'datetime', nullable: false)]
118
    protected DateTime $createdOn;
119
120
    #[Gedmo\Timestampable(on: 'update')]
121
    #[ORM\Column(name: 'modified_on', type: 'datetime', nullable: false)]
122
    protected DateTime $modifiedOn;
123
124
    #[ORM\Column(name: 'published_on', type: 'datetime', nullable: true)]
125
    protected ?DateTime $publishedOn;
126
127
    #[ORM\Column(name: 'expired_on', type: 'datetime', nullable: true)]
128
    protected ?DateTime $expiredOn = null;
129
130
    #[ORM\Column(name: 'accumulate_scorm_time', type: 'integer', nullable: false, options: ['default' => 1])]
131
    protected int $accumulateScormTime;
132
133
    #[ORM\Column(name: 'accumulate_work_time', type: 'integer', nullable: false, options: ['default' => 0])]
134
    protected int $accumulateWorkTime;
135
136
    #[ORM\Column(name: 'next_lp_id', type: 'integer', nullable: false, options: ['default' => 0])]
137
    protected int $nextLpId;
138
139
    #[ORM\OneToMany(mappedBy: 'lp', targetEntity: CLpItem::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
140
    protected Collection $items;
141
142
    /**
143
     * @var Collection<int, CForum>
144
     */
145
    #[ORM\OneToMany(mappedBy: 'lp', targetEntity: CForum::class, cascade: ['persist', 'remove'])]
146
    protected Collection $forums;
147
148
    #[ORM\ManyToOne(targetEntity: Asset::class, cascade: ['persist', 'remove'])]
149
    #[ORM\JoinColumn(name: 'asset_id', referencedColumnName: 'id')]
150
    protected ?Asset $asset = null;
151
152
    public function __construct()
153
    {
154
        $now = new DateTime();
155
        $this->createdOn = $now;
156
        $this->modifiedOn = $now;
157
        $this->publishedOn = $now;
158
        $this->accumulateScormTime = 1;
159
        $this->accumulateWorkTime = 0;
160
        $this->author = '';
161
        $this->autolaunch = 0;
162
        $this->contentLocal = 'local';
163
        $this->contentMaker = 'chamilo';
164
        $this->contentLicense = '';
165
        $this->defaultEncoding = 'UTF-8';
166
        $this->defaultViewMod = 'embedded';
167
        $this->description = '';
168
        $this->debug = false;
169
        $this->forceCommit = false;
170
        $this->hideTocFrame = false;
171
        $this->jsLib = '';
172
        $this->maxAttempts = 0;
173
        $this->preventReinit = true;
174
        $this->path = '';
175
        $this->prerequisite = 0;
176
        $this->seriousgameMode = false;
177
        $this->subscribeUsers = 0;
178
        $this->useMaxScore = 1;
179
        $this->theme = '';
180
        $this->nextLpId = 0;
181
        $this->items = new ArrayCollection();
182
        $this->forums = new ArrayCollection();
183
    }
184
185
    public function __toString(): string
186
    {
187
        return $this->getTitle();
188
    }
189
190
    public function setLpType(int $lpType): self
191
    {
192
        $this->lpType = $lpType;
193
194
        return $this;
195
    }
196
197
    public function getLpType(): int
198
    {
199
        return $this->lpType;
200
    }
201
202
    public function setTitle(string $title): self
203
    {
204
        $this->title = $title;
205
206
        return $this;
207
    }
208
209
    public function getTitle(): string
210
    {
211
        return $this->title;
212
    }
213
214
    public function setRef(string $ref): self
215
    {
216
        $this->ref = $ref;
217
218
        return $this;
219
    }
220
221
    public function getRef(): ?string
222
    {
223
        return $this->ref;
224
    }
225
226
    public function setDescription(string $description): self
227
    {
228
        $this->description = $description;
229
230
        return $this;
231
    }
232
233
    public function getDescription(): ?string
234
    {
235
        return $this->description;
236
    }
237
238
    public function setPath(string $path): self
239
    {
240
        $this->path = $path;
241
242
        return $this;
243
    }
244
245
    public function getPath(): string
246
    {
247
        return $this->path;
248
    }
249
250
    public function setForceCommit(bool $forceCommit): self
251
    {
252
        $this->forceCommit = $forceCommit;
253
254
        return $this;
255
    }
256
257
    public function getForceCommit(): bool
258
    {
259
        return $this->forceCommit;
260
    }
261
262
    public function setDefaultViewMod(string $defaultViewMod): self
263
    {
264
        $this->defaultViewMod = $defaultViewMod;
265
266
        return $this;
267
    }
268
269
    public function getDefaultViewMod(): string
270
    {
271
        return $this->defaultViewMod;
272
    }
273
274
    public function setDefaultEncoding(string $defaultEncoding): self
275
    {
276
        $this->defaultEncoding = $defaultEncoding;
277
278
        return $this;
279
    }
280
281
    public function getDefaultEncoding(): string
282
    {
283
        return $this->defaultEncoding;
284
    }
285
286
    public function setContentMaker(string $contentMaker): self
287
    {
288
        $this->contentMaker = $contentMaker;
289
290
        return $this;
291
    }
292
293
    public function getContentMaker(): string
294
    {
295
        return $this->contentMaker;
296
    }
297
298
    public function setContentLocal(string $contentLocal): self
299
    {
300
        $this->contentLocal = $contentLocal;
301
302
        return $this;
303
    }
304
305
    public function getContentLocal(): string
306
    {
307
        return $this->contentLocal;
308
    }
309
310
    public function setContentLicense(string $contentLicense): self
311
    {
312
        $this->contentLicense = $contentLicense;
313
314
        return $this;
315
    }
316
317
    public function getContentLicense(): string
318
    {
319
        return $this->contentLicense;
320
    }
321
322
    public function setPreventReinit(bool $preventReinit): self
323
    {
324
        $this->preventReinit = $preventReinit;
325
326
        return $this;
327
    }
328
329
    public function getPreventReinit(): bool
330
    {
331
        return $this->preventReinit;
332
    }
333
334
    public function setJsLib(string $jsLib): self
335
    {
336
        $this->jsLib = $jsLib;
337
338
        return $this;
339
    }
340
341
    public function getJsLib(): string
342
    {
343
        return $this->jsLib;
344
    }
345
346
    public function setDebug(bool $debug): self
347
    {
348
        $this->debug = $debug;
349
350
        return $this;
351
    }
352
353
    public function getDebug(): bool
354
    {
355
        return $this->debug;
356
    }
357
358
    public function setTheme(string $theme): self
359
    {
360
        $this->theme = $theme;
361
362
        return $this;
363
    }
364
365
    public function getTheme(): string
366
    {
367
        return $this->theme;
368
    }
369
370
    public function setAuthor(string $author): self
371
    {
372
        $this->author = $author;
373
374
        return $this;
375
    }
376
377
    public function getAuthor(): string
378
    {
379
        return $this->author;
380
    }
381
382
    public function setPrerequisite(int $prerequisite): self
383
    {
384
        $this->prerequisite = $prerequisite;
385
386
        return $this;
387
    }
388
389
    public function getPrerequisite(): int
390
    {
391
        return $this->prerequisite;
392
    }
393
394
    public function setHideTocFrame(bool $hideTocFrame): self
395
    {
396
        $this->hideTocFrame = $hideTocFrame;
397
398
        return $this;
399
    }
400
401
    public function getHideTocFrame(): bool
402
    {
403
        return $this->hideTocFrame;
404
    }
405
406
    public function setSeriousgameMode(bool $seriousgameMode): self
407
    {
408
        $this->seriousgameMode = $seriousgameMode;
409
410
        return $this;
411
    }
412
413
    public function getSeriousgameMode(): bool
414
    {
415
        return $this->seriousgameMode;
416
    }
417
418
    public function setUseMaxScore(int $useMaxScore): self
419
    {
420
        $this->useMaxScore = $useMaxScore;
421
422
        return $this;
423
    }
424
425
    public function getUseMaxScore(): int
426
    {
427
        return $this->useMaxScore;
428
    }
429
430
    public function setAutolaunch(int $autolaunch): self
431
    {
432
        $this->autolaunch = $autolaunch;
433
434
        return $this;
435
    }
436
437
    public function getAutolaunch(): int
438
    {
439
        return $this->autolaunch;
440
    }
441
442
    public function setCreatedOn(DateTime $createdOn): self
443
    {
444
        $this->createdOn = $createdOn;
445
446
        return $this;
447
    }
448
449
    public function getCreatedOn(): DateTime
450
    {
451
        return $this->createdOn;
452
    }
453
454
    public function setModifiedOn(DateTime $modifiedOn): self
455
    {
456
        $this->modifiedOn = $modifiedOn;
457
458
        return $this;
459
    }
460
461
    public function getModifiedOn(): DateTime
462
    {
463
        return $this->modifiedOn;
464
    }
465
466
    public function setPublishedOn(?DateTime $publishedOn): self
467
    {
468
        $this->publishedOn = $publishedOn;
469
470
        return $this;
471
    }
472
473
    public function getPublishedOn(): ?DateTime
474
    {
475
        return $this->publishedOn;
476
    }
477
478
    public function setExpiredOn(?DateTime $expiredOn): self
479
    {
480
        $this->expiredOn = $expiredOn;
481
482
        return $this;
483
    }
484
485
    public function getExpiredOn(): ?DateTime
486
    {
487
        return $this->expiredOn;
488
    }
489
490
    public function getCategory(): ?CLpCategory
491
    {
492
        return $this->category;
493
    }
494
495
    public function hasCategory(): bool
496
    {
497
        return null !== $this->category;
498
    }
499
500
    public function setCategory(?CLpCategory $category = null): self
501
    {
502
        $this->category = $category;
503
504
        return $this;
505
    }
506
507
    public function getAccumulateScormTime(): int
508
    {
509
        return $this->accumulateScormTime;
510
    }
511
512
    public function setAccumulateScormTime(int $accumulateScormTime): self
513
    {
514
        $this->accumulateScormTime = $accumulateScormTime;
515
516
        return $this;
517
    }
518
519
    public function getAccumulateWorkTime(): int
520
    {
521
        return $this->accumulateWorkTime;
522
    }
523
524
    public function setAccumulateWorkTime(int $accumulateWorkTime): self
525
    {
526
        $this->accumulateWorkTime = $accumulateWorkTime;
527
528
        return $this;
529
    }
530
531
    public function getMaxAttempts(): int
532
    {
533
        return $this->maxAttempts;
534
    }
535
536
    public function getNextLpId(): int
537
    {
538
        return $this->nextLpId;
539
    }
540
541
    public function setNextLpId(int $nextLpId): self
542
    {
543
        $this->nextLpId = $nextLpId;
544
545
        return $this;
546
    }
547
548
    /**
549
     * @return Collection<int, CLpItem>
550
     */
551
    public function getItems(): Collection
552
    {
553
        return $this->items;
554
    }
555
556
    public function getIid(): ?int
557
    {
558
        return $this->iid;
559
    }
560
561
    public function getSubscribeUsers(): int
562
    {
563
        return $this->subscribeUsers;
564
    }
565
566
    public function setSubscribeUsers(int $value): self
567
    {
568
        $this->subscribeUsers = $value;
569
570
        return $this;
571
    }
572
573
    /**
574
     * @return Collection<int, CForum>
575
     */
576
    public function getForums(): Collection
577
    {
578
        return $this->forums;
579
    }
580
581
    public function setForums(ArrayCollection|Collection $forums): self
582
    {
583
        $this->forums = $forums;
584
585
        return $this;
586
    }
587
588
    public function getAsset(): ?Asset
589
    {
590
        return $this->asset;
591
    }
592
593
    public function hasAsset(): bool
594
    {
595
        return null !== $this->asset;
596
    }
597
598
    public function setAsset(?Asset $asset): self
599
    {
600
        $this->asset = $asset;
601
602
        return $this;
603
    }
604
605
    public function getResourceIdentifier(): int|Uuid
606
    {
607
        return $this->getIid();
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getIid() could return the type null which is incompatible with the type-hinted return Symfony\Component\Uid\Uuid|integer. Consider adding an additional type-check to rule them out.
Loading history...
608
    }
609
610
    public function getResourceName(): string
611
    {
612
        return $this->getTitle();
613
    }
614
615
    public function setResourceName(string $name): self
616
    {
617
        return $this->setTitle($name);
618
    }
619
}
620