1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* For licensing terms, see /license.txt */ |
6
|
|
|
|
7
|
|
|
namespace Chamilo\CoreBundle\Entity; |
8
|
|
|
|
9
|
|
|
use DateTime; |
10
|
|
|
use Doctrine\ORM\Mapping as ORM; |
11
|
|
|
use Symfony\Component\Uid\Uuid; |
12
|
|
|
|
13
|
|
|
#[ORM\Entity] |
14
|
|
|
#[ORM\Table(name: 'portfolio_comment')] |
15
|
|
|
class PortfolioComment extends AbstractResource implements ResourceInterface, \Stringable |
16
|
|
|
{ |
17
|
|
|
public const VISIBILITY_VISIBLE = 1; |
18
|
|
|
public const VISIBILITY_PER_USER = 2; |
19
|
|
|
|
20
|
|
|
#[ORM\Column(type: 'smallint', options: ['default' => self::VISIBILITY_VISIBLE])] |
21
|
|
|
protected int $visibility; |
22
|
|
|
|
23
|
|
|
#[ORM\Id] |
24
|
|
|
#[ORM\GeneratedValue] |
25
|
|
|
#[ORM\Column(type: 'integer')] |
26
|
|
|
private int $id; |
27
|
|
|
|
28
|
|
|
#[ORM\ManyToOne(targetEntity: Portfolio::class, inversedBy: 'comments')] |
29
|
|
|
#[ORM\JoinColumn(name: 'item_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')] |
30
|
|
|
private Portfolio $item; |
31
|
|
|
|
32
|
|
|
#[ORM\Column(type: 'text')] |
33
|
|
|
private string $content; |
34
|
|
|
|
35
|
|
|
#[ORM\Column(type: 'datetime')] |
36
|
|
|
private DateTime $date; |
37
|
|
|
|
38
|
|
|
#[ORM\Column(type: 'boolean', options: ['default' => false])] |
39
|
|
|
private bool $isImportant; |
40
|
|
|
|
41
|
|
|
#[ORM\Column(type: 'float', nullable: true)] |
42
|
|
|
private ?float $score; |
43
|
|
|
|
44
|
|
|
#[ORM\Column(type: 'boolean', options: ['default' => false])] |
45
|
|
|
private bool $isTemplate = false; |
46
|
|
|
|
47
|
|
|
public function __construct() |
48
|
|
|
{ |
49
|
|
|
$this->isImportant = false; |
50
|
|
|
$this->visibility = self::VISIBILITY_VISIBLE; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function getId(): int |
54
|
|
|
{ |
55
|
|
|
return $this->id; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function getItem(): Portfolio |
59
|
|
|
{ |
60
|
|
|
return $this->item; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function setItem(Portfolio $item): self |
64
|
|
|
{ |
65
|
|
|
$this->item = $item; |
66
|
|
|
|
67
|
|
|
return $this; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function getContent(): string |
71
|
|
|
{ |
72
|
|
|
return $this->content; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function setContent(string $content): self |
76
|
|
|
{ |
77
|
|
|
$this->content = $content; |
78
|
|
|
|
79
|
|
|
return $this; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function getDate(): DateTime |
83
|
|
|
{ |
84
|
|
|
return $this->date; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public function setDate(DateTime $date): self |
88
|
|
|
{ |
89
|
|
|
$this->date = $date; |
90
|
|
|
|
91
|
|
|
return $this; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
public function isImportant(): bool |
95
|
|
|
{ |
96
|
|
|
return $this->isImportant; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
public function setIsImportant(bool $isImportant): void |
100
|
|
|
{ |
101
|
|
|
$this->isImportant = $isImportant; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
public function getExcerpt(int $count = 190): string |
105
|
|
|
{ |
106
|
|
|
return api_get_short_text_from_html($this->content, $count); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
public function getScore(): ?float |
110
|
|
|
{ |
111
|
|
|
return $this->score; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
public function setScore(?float $score): void |
115
|
|
|
{ |
116
|
|
|
$this->score = $score; |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
public function isTemplate(): bool |
120
|
|
|
{ |
121
|
|
|
return $this->isTemplate; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
public function setIsTemplate(bool $isTemplate): self |
125
|
|
|
{ |
126
|
|
|
$this->isTemplate = $isTemplate; |
127
|
|
|
|
128
|
|
|
return $this; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
public function getVisibility(): int |
132
|
|
|
{ |
133
|
|
|
return $this->visibility; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
public function setVisibility(int $visibility): self |
137
|
|
|
{ |
138
|
|
|
$this->visibility = $visibility; |
139
|
|
|
|
140
|
|
|
return $this; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
public function getResourceName(): string |
144
|
|
|
{ |
145
|
|
|
return 'portfolio_comment_'.$this->id; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
public function setResourceName(string $name): static |
149
|
|
|
{ |
150
|
|
|
return $this->setContent($name); |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
public function __toString(): string |
154
|
|
|
{ |
155
|
|
|
return $this->getContent(); |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
public function getResourceIdentifier(): int|Uuid |
159
|
|
|
{ |
160
|
|
|
return $this->getId(); |
161
|
|
|
} |
162
|
|
|
} |
163
|
|
|
|