CWiki::getIsEditing()   A
last analyzed

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\CourseBundle\Repository\CWikiRepository;
12
use DateTime;
13
use Doctrine\Common\Collections\ArrayCollection;
14
use Doctrine\Common\Collections\Collection;
15
use Doctrine\ORM\Mapping as ORM;
16
use Stringable;
17
use Symfony\Component\Uid\Uuid;
18
use Symfony\Component\Validator\Constraints as Assert;
19
20
#[ORM\Table(name: 'c_wiki', options: ['row_format' => 'DYNAMIC'])]
21
#[ORM\Index(columns: ['c_id'], name: 'course')]
22
#[ORM\Index(columns: ['reflink'], name: 'reflink')]
23
#[ORM\Index(columns: ['group_id'], name: 'group_id')]
24
#[ORM\Index(columns: ['page_id'], name: 'page_id')]
25
#[ORM\Index(columns: ['session_id'], name: 'session_id')]
26
#[ORM\Entity(repositoryClass: CWikiRepository::class)]
27
class CWiki extends AbstractResource implements ResourceInterface, Stringable
28
{
29
    #[ORM\Column(name: 'iid', type: 'integer')]
30
    #[ORM\Id]
31
    #[ORM\GeneratedValue]
32
    protected ?int $iid = null;
33
34
    #[ORM\Column(name: 'c_id', type: 'integer')]
35
    protected int $cId;
36
37
    #[ORM\Column(name: 'page_id', type: 'integer', nullable: true)]
38
    protected ?int $pageId = null;
39
40
    #[ORM\Column(name: 'reflink', type: 'string', length: 255, nullable: false)]
41
    protected string $reflink;
42
43
    #[Assert\NotBlank]
44
    #[ORM\Column(name: 'title', type: 'string', length: 255, nullable: false)]
45
    protected string $title;
46
47
    #[Assert\NotBlank]
48
    #[ORM\Column(name: 'content', type: 'text', nullable: false)]
49
    protected string $content;
50
51
    #[ORM\Column(name: 'user_id', type: 'integer', nullable: false)]
52
    protected int $userId;
53
54
    #[ORM\Column(name: 'group_id', type: 'integer', nullable: true)]
55
    protected ?int $groupId = null;
56
57
    #[ORM\Column(name: 'dtime', type: 'datetime', nullable: true)]
58
    protected ?DateTime $dtime = null;
59
60
    #[ORM\Column(name: 'addlock', type: 'integer', nullable: false)]
61
    protected int $addlock;
62
63
    #[ORM\Column(name: 'editlock', type: 'integer', nullable: false)]
64
    protected int $editlock;
65
66
    #[ORM\Column(name: 'visibility', type: 'integer', nullable: false)]
67
    protected int $visibility;
68
69
    #[ORM\Column(name: 'addlock_disc', type: 'integer', nullable: false)]
70
    protected int $addlockDisc;
71
72
    #[ORM\Column(name: 'visibility_disc', type: 'integer', nullable: false)]
73
    protected int $visibilityDisc;
74
75
    #[ORM\Column(name: 'ratinglock_disc', type: 'integer', nullable: false)]
76
    protected int $ratinglockDisc;
77
78
    #[ORM\Column(name: 'assignment', type: 'integer', nullable: false)]
79
    protected int $assignment;
80
81
    #[ORM\Column(name: 'comment', type: 'text', nullable: false)]
82
    protected string $comment;
83
84
    #[ORM\Column(name: 'progress', type: 'text', nullable: false)]
85
    protected string $progress;
86
87
    #[ORM\Column(name: 'score', type: 'integer', nullable: true)]
88
    protected ?int $score = null;
89
90
    #[ORM\Column(name: 'version', type: 'integer', nullable: true)]
91
    protected ?int $version = null;
92
93
    #[ORM\Column(name: 'is_editing', type: 'integer', nullable: false)]
94
    protected int $isEditing;
95
96
    #[ORM\Column(name: 'time_edit', type: 'datetime', nullable: true)]
97
    protected ?DateTime $timeEdit = null;
98
99
    #[ORM\Column(name: 'hits', type: 'integer', nullable: true)]
100
    protected ?int $hits = null;
101
102
    #[ORM\Column(name: 'linksto', type: 'text', nullable: false)]
103
    protected string $linksto;
104
105
    #[ORM\Column(name: 'tag', type: 'text', nullable: false)]
106
    protected string $tag;
107
108
    #[ORM\Column(name: 'user_ip', type: 'string', length: 45, nullable: false)]
109
    protected string $userIp;
110
111
    #[ORM\Column(name: 'session_id', type: 'integer', nullable: true)]
112
    protected ?int $sessionId = null;
113
114
    /**
115
     * @var Collection<int, CWikiCategory>
116
     */
117
    #[ORM\ManyToMany(targetEntity: CWikiCategory::class, inversedBy: 'wikiPages')]
118
    #[ORM\JoinTable(name: 'c_wiki_rel_category')]
119
    #[ORM\JoinColumn(name: 'wiki_id', referencedColumnName: 'iid', onDelete: 'CASCADE')]
120
    #[ORM\InverseJoinColumn(name: 'category_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
121
    private Collection $categories;
122
123
    public function __construct()
124
    {
125
        $this->categories = new ArrayCollection();
126
    }
127
128
    public function __toString(): string
129
    {
130
        return $this->getTitle();
131
    }
132
133
    public function getTitle(): string
134
    {
135
        return $this->title;
136
    }
137
138
    public function setTitle(string $title): static
139
    {
140
        $this->title = $title;
141
142
        return $this;
143
    }
144
145
    public function getPageId(): ?int
146
    {
147
        return $this->pageId;
148
    }
149
150
    public function setPageId(int $pageId): static
151
    {
152
        $this->pageId = $pageId;
153
154
        return $this;
155
    }
156
157
    public function getReflink(): string
158
    {
159
        return $this->reflink;
160
    }
161
162
    public function setReflink(string $reflink): static
163
    {
164
        $this->reflink = $reflink;
165
166
        return $this;
167
    }
168
169
    public function getContent(): string
170
    {
171
        return $this->content;
172
    }
173
174
    public function setContent(string $content): static
175
    {
176
        $this->content = $content;
177
178
        return $this;
179
    }
180
181
    public function getUserId(): int
182
    {
183
        return $this->userId;
184
    }
185
186
    public function setUserId(int $userId): static
187
    {
188
        $this->userId = $userId;
189
190
        return $this;
191
    }
192
193
    public function getGroupId(): ?int
194
    {
195
        return $this->groupId;
196
    }
197
198
    public function setGroupId(int $groupId): static
199
    {
200
        $this->groupId = $groupId;
201
202
        return $this;
203
    }
204
205
    public function getDtime(): ?DateTime
206
    {
207
        return $this->dtime;
208
    }
209
210
    public function setDtime(DateTime $dtime): static
211
    {
212
        $this->dtime = $dtime;
213
214
        return $this;
215
    }
216
217
    public function getAddlock(): int
218
    {
219
        return $this->addlock;
220
    }
221
222
    public function setAddlock(int $addlock): static
223
    {
224
        $this->addlock = $addlock;
225
226
        return $this;
227
    }
228
229
    public function getEditlock(): int
230
    {
231
        return $this->editlock;
232
    }
233
234
    public function setEditlock(int $editlock): static
235
    {
236
        $this->editlock = $editlock;
237
238
        return $this;
239
    }
240
241
    public function getVisibility(): int
242
    {
243
        return $this->visibility;
244
    }
245
246
    public function setVisibility(int $visibility): static
247
    {
248
        $this->visibility = $visibility;
249
250
        return $this;
251
    }
252
253
    public function getAddlockDisc(): int
254
    {
255
        return $this->addlockDisc;
256
    }
257
258
    public function setAddlockDisc(int $addlockDisc): static
259
    {
260
        $this->addlockDisc = $addlockDisc;
261
262
        return $this;
263
    }
264
265
    public function getVisibilityDisc(): int
266
    {
267
        return $this->visibilityDisc;
268
    }
269
270
    public function setVisibilityDisc(int $visibilityDisc): static
271
    {
272
        $this->visibilityDisc = $visibilityDisc;
273
274
        return $this;
275
    }
276
277
    public function getRatinglockDisc(): int
278
    {
279
        return $this->ratinglockDisc;
280
    }
281
282
    public function setRatinglockDisc(int $ratinglockDisc): static
283
    {
284
        $this->ratinglockDisc = $ratinglockDisc;
285
286
        return $this;
287
    }
288
289
    public function getAssignment(): int
290
    {
291
        return $this->assignment;
292
    }
293
294
    public function setAssignment(int $assignment): static
295
    {
296
        $this->assignment = $assignment;
297
298
        return $this;
299
    }
300
301
    public function getComment(): string
302
    {
303
        return $this->comment;
304
    }
305
306
    public function setComment(string $comment): static
307
    {
308
        $this->comment = $comment;
309
310
        return $this;
311
    }
312
313
    public function getProgress(): string
314
    {
315
        return $this->progress;
316
    }
317
318
    public function setProgress(string $progress): static
319
    {
320
        $this->progress = $progress;
321
322
        return $this;
323
    }
324
325
    public function getScore(): ?int
326
    {
327
        return $this->score;
328
    }
329
330
    public function setScore(int $score): static
331
    {
332
        $this->score = $score;
333
334
        return $this;
335
    }
336
337
    public function getVersion(): ?int
338
    {
339
        return $this->version;
340
    }
341
342
    public function setVersion(int $version): static
343
    {
344
        $this->version = $version;
345
346
        return $this;
347
    }
348
349
    public function getIsEditing(): int
350
    {
351
        return $this->isEditing;
352
    }
353
354
    public function setIsEditing(int $isEditing): static
355
    {
356
        $this->isEditing = $isEditing;
357
358
        return $this;
359
    }
360
361
    public function getTimeEdit(): ?DateTime
362
    {
363
        return $this->timeEdit;
364
    }
365
366
    public function setTimeEdit(DateTime $timeEdit): static
367
    {
368
        $this->timeEdit = $timeEdit;
369
370
        return $this;
371
    }
372
373
    public function getHits(): ?int
374
    {
375
        return $this->hits;
376
    }
377
378
    public function setHits(int $hits): static
379
    {
380
        $this->hits = $hits;
381
382
        return $this;
383
    }
384
385
    public function getLinksto(): string
386
    {
387
        return $this->linksto;
388
    }
389
390
    public function setLinksto(string $linksto): static
391
    {
392
        $this->linksto = $linksto;
393
394
        return $this;
395
    }
396
397
    public function getTag(): string
398
    {
399
        return $this->tag;
400
    }
401
402
    public function setTag(string $tag): static
403
    {
404
        $this->tag = $tag;
405
406
        return $this;
407
    }
408
409
    public function getUserIp(): string
410
    {
411
        return $this->userIp;
412
    }
413
414
    public function setUserIp(string $userIp): static
415
    {
416
        $this->userIp = $userIp;
417
418
        return $this;
419
    }
420
421
    public function getSessionId(): ?int
422
    {
423
        return $this->sessionId;
424
    }
425
426
    public function setSessionId(int $sessionId): static
427
    {
428
        $this->sessionId = $sessionId;
429
430
        return $this;
431
    }
432
433
    public function getCId(): int
434
    {
435
        return $this->cId;
436
    }
437
438
    public function setCId(int $cId): static
439
    {
440
        $this->cId = $cId;
441
442
        return $this;
443
    }
444
445
    public function getResourceIdentifier(): int|Uuid
446
    {
447
        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...
448
    }
449
450
    public function getIid(): ?int
451
    {
452
        return $this->iid;
453
    }
454
455
    public function getResourceName(): string
456
    {
457
        return $this->getTitle();
458
    }
459
460
    /**
461
     * @return Collection<int, CWikiCategory>
462
     */
463
    public function getCategories(): Collection
464
    {
465
        return $this->categories;
466
    }
467
468
    public function addCategory(CWikiCategory $category): self
469
    {
470
        $category->addWikiPage($this);
471
        $this->categories->add($category);
472
473
        return $this;
474
    }
475
476
    public function setResourceName(string $name): self
477
    {
478
        return $this->setTitle($name);
479
    }
480
}
481