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