Completed
Push — master ( d9adeb...430d2c )
by
unknown
01:15 queued 37s
created

CLp::setHideTocFrame()   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
    #[ORM\Column(name: 'duration', type: 'integer', nullable: true)]
153
    protected ?int $duration = null;
154
155
    public function __construct()
156
    {
157
        $now = new DateTime();
158
        $this->createdOn = $now;
159
        $this->modifiedOn = $now;
160
        $this->publishedOn = $now;
161
        $this->accumulateScormTime = 1;
162
        $this->accumulateWorkTime = 0;
163
        $this->author = '';
164
        $this->autolaunch = 0;
165
        $this->contentLocal = 'local';
166
        $this->contentMaker = 'chamilo';
167
        $this->contentLicense = '';
168
        $this->defaultEncoding = 'UTF-8';
169
        $this->defaultViewMod = 'embedded';
170
        $this->description = '';
171
        $this->debug = false;
172
        $this->forceCommit = false;
173
        $this->hideTocFrame = false;
174
        $this->jsLib = '';
175
        $this->maxAttempts = 0;
176
        $this->preventReinit = true;
177
        $this->path = '';
178
        $this->prerequisite = 0;
179
        $this->seriousgameMode = false;
180
        $this->subscribeUsers = 0;
181
        $this->useMaxScore = 1;
182
        $this->theme = '';
183
        $this->nextLpId = 0;
184
        $this->items = new ArrayCollection();
185
        $this->forums = new ArrayCollection();
186
    }
187
188
    public function __toString(): string
189
    {
190
        return $this->getTitle();
191
    }
192
193
    public function setLpType(int $lpType): self
194
    {
195
        $this->lpType = $lpType;
196
197
        return $this;
198
    }
199
200
    public function getLpType(): int
201
    {
202
        return $this->lpType;
203
    }
204
205
    public function setTitle(string $title): self
206
    {
207
        $this->title = $title;
208
209
        return $this;
210
    }
211
212
    public function getTitle(): string
213
    {
214
        return $this->title;
215
    }
216
217
    public function setRef(string $ref): self
218
    {
219
        $this->ref = $ref;
220
221
        return $this;
222
    }
223
224
    public function getRef(): ?string
225
    {
226
        return $this->ref;
227
    }
228
229
    public function setDescription(string $description): self
230
    {
231
        $this->description = $description;
232
233
        return $this;
234
    }
235
236
    public function getDescription(): ?string
237
    {
238
        return $this->description;
239
    }
240
241
    public function setPath(string $path): self
242
    {
243
        $this->path = $path;
244
245
        return $this;
246
    }
247
248
    public function getPath(): string
249
    {
250
        return $this->path;
251
    }
252
253
    public function setForceCommit(bool $forceCommit): self
254
    {
255
        $this->forceCommit = $forceCommit;
256
257
        return $this;
258
    }
259
260
    public function getForceCommit(): bool
261
    {
262
        return $this->forceCommit;
263
    }
264
265
    public function setDefaultViewMod(string $defaultViewMod): self
266
    {
267
        $this->defaultViewMod = $defaultViewMod;
268
269
        return $this;
270
    }
271
272
    public function getDefaultViewMod(): string
273
    {
274
        return $this->defaultViewMod;
275
    }
276
277
    public function setDefaultEncoding(string $defaultEncoding): self
278
    {
279
        $this->defaultEncoding = $defaultEncoding;
280
281
        return $this;
282
    }
283
284
    public function getDefaultEncoding(): string
285
    {
286
        return $this->defaultEncoding;
287
    }
288
289
    public function setContentMaker(string $contentMaker): self
290
    {
291
        $this->contentMaker = $contentMaker;
292
293
        return $this;
294
    }
295
296
    public function getContentMaker(): string
297
    {
298
        return $this->contentMaker;
299
    }
300
301
    public function setContentLocal(string $contentLocal): self
302
    {
303
        $this->contentLocal = $contentLocal;
304
305
        return $this;
306
    }
307
308
    public function getContentLocal(): string
309
    {
310
        return $this->contentLocal;
311
    }
312
313
    public function setContentLicense(string $contentLicense): self
314
    {
315
        $this->contentLicense = $contentLicense;
316
317
        return $this;
318
    }
319
320
    public function getContentLicense(): string
321
    {
322
        return $this->contentLicense;
323
    }
324
325
    public function setPreventReinit(bool $preventReinit): self
326
    {
327
        $this->preventReinit = $preventReinit;
328
329
        return $this;
330
    }
331
332
    public function getPreventReinit(): bool
333
    {
334
        return $this->preventReinit;
335
    }
336
337
    public function setJsLib(string $jsLib): self
338
    {
339
        $this->jsLib = $jsLib;
340
341
        return $this;
342
    }
343
344
    public function getJsLib(): string
345
    {
346
        return $this->jsLib;
347
    }
348
349
    public function setDebug(bool $debug): self
350
    {
351
        $this->debug = $debug;
352
353
        return $this;
354
    }
355
356
    public function getDebug(): bool
357
    {
358
        return $this->debug;
359
    }
360
361
    public function setTheme(string $theme): self
362
    {
363
        $this->theme = $theme;
364
365
        return $this;
366
    }
367
368
    public function getTheme(): string
369
    {
370
        return $this->theme;
371
    }
372
373
    public function setAuthor(string $author): self
374
    {
375
        $this->author = $author;
376
377
        return $this;
378
    }
379
380
    public function getAuthor(): string
381
    {
382
        return $this->author;
383
    }
384
385
    public function setPrerequisite(int $prerequisite): self
386
    {
387
        $this->prerequisite = $prerequisite;
388
389
        return $this;
390
    }
391
392
    public function getPrerequisite(): int
393
    {
394
        return $this->prerequisite;
395
    }
396
397
    public function setHideTocFrame(bool $hideTocFrame): self
398
    {
399
        $this->hideTocFrame = $hideTocFrame;
400
401
        return $this;
402
    }
403
404
    public function getHideTocFrame(): bool
405
    {
406
        return $this->hideTocFrame;
407
    }
408
409
    public function setSeriousgameMode(bool $seriousgameMode): self
410
    {
411
        $this->seriousgameMode = $seriousgameMode;
412
413
        return $this;
414
    }
415
416
    public function getSeriousgameMode(): bool
417
    {
418
        return $this->seriousgameMode;
419
    }
420
421
    public function setUseMaxScore(int $useMaxScore): self
422
    {
423
        $this->useMaxScore = $useMaxScore;
424
425
        return $this;
426
    }
427
428
    public function getUseMaxScore(): int
429
    {
430
        return $this->useMaxScore;
431
    }
432
433
    public function setAutolaunch(int $autolaunch): self
434
    {
435
        $this->autolaunch = $autolaunch;
436
437
        return $this;
438
    }
439
440
    public function getAutolaunch(): int
441
    {
442
        return $this->autolaunch;
443
    }
444
445
    public function setCreatedOn(DateTime $createdOn): self
446
    {
447
        $this->createdOn = $createdOn;
448
449
        return $this;
450
    }
451
452
    public function getCreatedOn(): DateTime
453
    {
454
        return $this->createdOn;
455
    }
456
457
    public function setModifiedOn(DateTime $modifiedOn): self
458
    {
459
        $this->modifiedOn = $modifiedOn;
460
461
        return $this;
462
    }
463
464
    public function getModifiedOn(): DateTime
465
    {
466
        return $this->modifiedOn;
467
    }
468
469
    public function setPublishedOn(?DateTime $publishedOn): self
470
    {
471
        $this->publishedOn = $publishedOn;
472
473
        return $this;
474
    }
475
476
    public function getPublishedOn(): ?DateTime
477
    {
478
        return $this->publishedOn;
479
    }
480
481
    public function setExpiredOn(?DateTime $expiredOn): self
482
    {
483
        $this->expiredOn = $expiredOn;
484
485
        return $this;
486
    }
487
488
    public function getExpiredOn(): ?DateTime
489
    {
490
        return $this->expiredOn;
491
    }
492
493
    public function getCategory(): ?CLpCategory
494
    {
495
        return $this->category;
496
    }
497
498
    public function hasCategory(): bool
499
    {
500
        return null !== $this->category;
501
    }
502
503
    public function setCategory(?CLpCategory $category = null): self
504
    {
505
        $this->category = $category;
506
507
        return $this;
508
    }
509
510
    public function getAccumulateScormTime(): int
511
    {
512
        return $this->accumulateScormTime;
513
    }
514
515
    public function setAccumulateScormTime(int $accumulateScormTime): self
516
    {
517
        $this->accumulateScormTime = $accumulateScormTime;
518
519
        return $this;
520
    }
521
522
    public function getAccumulateWorkTime(): int
523
    {
524
        return $this->accumulateWorkTime;
525
    }
526
527
    public function setAccumulateWorkTime(int $accumulateWorkTime): self
528
    {
529
        $this->accumulateWorkTime = $accumulateWorkTime;
530
531
        return $this;
532
    }
533
534
    public function getMaxAttempts(): int
535
    {
536
        return $this->maxAttempts;
537
    }
538
539
    public function getNextLpId(): int
540
    {
541
        return $this->nextLpId;
542
    }
543
544
    public function setNextLpId(int $nextLpId): self
545
    {
546
        $this->nextLpId = $nextLpId;
547
548
        return $this;
549
    }
550
551
    /**
552
     * @return Collection<int, CLpItem>
553
     */
554
    public function getItems(): Collection
555
    {
556
        return $this->items;
557
    }
558
559
    public function getIid(): ?int
560
    {
561
        return $this->iid;
562
    }
563
564
    public function getSubscribeUsers(): int
565
    {
566
        return $this->subscribeUsers;
567
    }
568
569
    public function setSubscribeUsers(int $value): self
570
    {
571
        $this->subscribeUsers = $value;
572
573
        return $this;
574
    }
575
576
    /**
577
     * @return Collection<int, CForum>
578
     */
579
    public function getForums(): Collection
580
    {
581
        return $this->forums;
582
    }
583
584
    public function setForums(ArrayCollection|Collection $forums): self
585
    {
586
        $this->forums = $forums;
587
588
        return $this;
589
    }
590
591
    public function getAsset(): ?Asset
592
    {
593
        return $this->asset;
594
    }
595
596
    public function hasAsset(): bool
597
    {
598
        return null !== $this->asset;
599
    }
600
601
    public function setAsset(?Asset $asset): self
602
    {
603
        $this->asset = $asset;
604
605
        return $this;
606
    }
607
608
    public function getDuration(): ?int
609
    {
610
        return $this->duration;
611
    }
612
613
    public function setDuration(?int $duration): self
614
    {
615
        $this->duration = $duration;
616
617
        return $this;
618
    }
619
620
    public function getResourceIdentifier(): int|Uuid
621
    {
622
        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...
623
    }
624
625
    public function getResourceName(): string
626
    {
627
        return $this->getTitle();
628
    }
629
630
    public function setResourceName(string $name): self
631
    {
632
        return $this->setTitle($name);
633
    }
634
}
635