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