Passed
Pull Request — 1.11.x (#4600)
by Angel Fernando Quiroz
22:19 queued 10:54
created

PortfolioComment::getAuthor()   A

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
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
/* For licensing terms, see /license.txt */
4
5
namespace Chamilo\CoreBundle\Entity;
6
7
use Chamilo\UserBundle\Entity\User;
8
use DateTime;
9
use Doctrine\Common\Collections\ArrayCollection;
10
use Doctrine\ORM\Mapping as ORM;
11
use Gedmo\Mapping\Annotation as Gedmo;
12
13
/**
14
 * Class PortfolioComment.
15
 *
16
 * @package Chamilo\CoreBundle\Entity
17
 *
18
 * @Gedmo\Tree(type="nested")
19
 * @ORM\Table(name="portfolio_comment")
20
 * Add @ to the next line if api_get_configuration_value('allow_portfolio_tool') is true
21
 * ORM\Entity(repositoryClass="Chamilo\CoreBundle\Entity\Repository\PortfolioCommentRepository")
22
 */
23
class PortfolioComment
24
{
25
    public const VISIBILITY_VISIBLE = 1;
26
    public const VISIBILITY_PER_USER = 2;
27
28
    /**
29
     * @var int
30
     *
31
     * Add @ to the next line if portfolio_advanced_sharing config setting is true
32
     * ORM\Column(name="visibility", type="smallint", options={"default": 1})
33
     */
34
    protected $visibility = 1;
35
36
    /**
37
     * @var int
38
     *
39
     * @ORM\Column(name="id", type="integer")
40
     * @ORM\Id
41
     * @ORM\GeneratedValue
42
     */
43
    private $id;
44
    /**
45
     * @var \Chamilo\UserBundle\Entity\User
46
     *
47
     * @ORM\ManyToOne(targetEntity="Chamilo\UserBundle\Entity\User")
48
     * @ORM\JoinColumn(name="author_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
49
     */
50
    private $author;
51
    /**
52
     * @var \Chamilo\CoreBundle\Entity\Portfolio
53
     *
54
     * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Portfolio", inversedBy="comments")
55
     * @ORM\JoinColumn(name="item_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
56
     */
57
    private $item;
58
    /**
59
     * @var string
60
     *
61
     * @ORM\Column(name="content", type="text")
62
     */
63
    private $content;
64
    /**
65
     * @var \DateTime
66
     *
67
     * @ORM\Column(name="date", type="datetime")
68
     */
69
    private $date;
70
    /**
71
     * @var bool
72
     *
73
     * @ORM\Column(name="is_important", type="boolean", options={"default":false})
74
     */
75
    private $isImportant;
76
    /**
77
     * @var int
78
     *
79
     * @Gedmo\TreeLeft()
80
     * @ORM\Column(name="lft", type="integer")
81
     */
82
    private $lft;
0 ignored issues
show
introduced by
The private property $lft is not used, and could be removed.
Loading history...
83
    /**
84
     * @var int
85
     *
86
     * @Gedmo\TreeLevel()
87
     * @ORM\Column(name="lvl", type="integer")
88
     */
89
    private $lvl;
90
    /**
91
     * @var int
92
     *
93
     * @Gedmo\TreeRight()
94
     * @ORM\Column(name="rgt", type="integer")
95
     */
96
    private $rgt;
0 ignored issues
show
introduced by
The private property $rgt is not used, and could be removed.
Loading history...
97
    /**
98
     * @var \Chamilo\CoreBundle\Entity\PortfolioComment
99
     *
100
     * @Gedmo\TreeRoot()
101
     * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\PortfolioComment")
102
     * @ORM\JoinColumn(name="tree_root", referencedColumnName="id", onDelete="CASCADE")
103
     */
104
    private $root;
105
    /**
106
     * @var \Chamilo\CoreBundle\Entity\PortfolioComment|null
107
     *
108
     * @Gedmo\TreeParent()
109
     * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\PortfolioComment", inversedBy="children")
110
     * @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="CASCADE")
111
     */
112
    private $parent;
113
    /**
114
     * @var \Doctrine\Common\Collections\ArrayCollection
115
     *
116
     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\PortfolioComment", mappedBy="parent")
117
     * @ORM\OrderBy({"lft"="DESC"})
118
     */
119
    private $children;
120
121
    /**
122
     * @var float|null
123
     *
124
     * @ORM\Column(name="score", type="float", nullable=true)
125
     */
126
    private $score;
127
128
    /**
129
     * @var bool
130
     *
131
     * @ORM\Column(name="is_template", type="boolean", options={"default": false})
132
     */
133
    private $isTemplate = false;
134
135
    /**
136
     * PortfolioComment constructor.
137
     */
138
    public function __construct()
139
    {
140
        $this->isImportant = false;
141
        $this->children = new ArrayCollection();
142
        $this->visibility = 1;
143
    }
144
145
    public function getId(): int
146
    {
147
        return $this->id;
148
    }
149
150
    public function getAuthor(): User
151
    {
152
        return $this->author;
153
    }
154
155
    public function setAuthor(User $author): PortfolioComment
156
    {
157
        $this->author = $author;
158
159
        return $this;
160
    }
161
162
    /**
163
     * @return \Chamilo\CoreBundle\Entity\Portfolio
164
     */
165
    public function getItem(): Portfolio
166
    {
167
        return $this->item;
168
    }
169
170
    /**
171
     * @param \Chamilo\CoreBundle\Entity\Portfolio $item
172
     */
173
    public function setItem(Portfolio $item): PortfolioComment
174
    {
175
        $this->item = $item;
176
177
        return $this;
178
    }
179
180
    public function getContent(): string
181
    {
182
        return $this->content;
183
    }
184
185
    public function setContent(string $content): PortfolioComment
186
    {
187
        $this->content = $content;
188
189
        return $this;
190
    }
191
192
    public function getDate(): DateTime
193
    {
194
        return $this->date;
195
    }
196
197
    public function setDate(DateTime $date): PortfolioComment
198
    {
199
        $this->date = $date;
200
201
        return $this;
202
    }
203
204
    /**
205
     * @return \Chamilo\CoreBundle\Entity\PortfolioComment|null
206
     */
207
    public function getParent(): ?PortfolioComment
208
    {
209
        return $this->parent;
210
    }
211
212
    /**
213
     * @param \Chamilo\CoreBundle\Entity\PortfolioComment|null $parent
214
     */
215
    public function setParent(?PortfolioComment $parent): PortfolioComment
216
    {
217
        $this->parent = $parent;
218
219
        return $this;
220
    }
221
222
    public function getChildren(): ArrayCollection
223
    {
224
        return $this->children;
225
    }
226
227
    public function setChildren(ArrayCollection $children): PortfolioComment
228
    {
229
        $this->children = $children;
230
231
        return $this;
232
    }
233
234
    public function isImportant(): bool
235
    {
236
        return $this->isImportant;
237
    }
238
239
    public function setIsImportant(bool $isImportant): void
240
    {
241
        $this->isImportant = $isImportant;
242
    }
243
244
    public function getExcerpt(int $count = 190): string
245
    {
246
        return api_get_short_text_from_html($this->content, $count);
247
    }
248
249
    public function getScore(): ?float
250
    {
251
        return $this->score;
252
    }
253
254
    public function setScore(?float $score): void
255
    {
256
        $this->score = $score;
257
    }
258
259
    /**
260
     * @return \Chamilo\CoreBundle\Entity\PortfolioComment
261
     */
262
    public function getRoot(): PortfolioComment
263
    {
264
        return $this->root;
265
    }
266
267
    public function getLvl(): int
268
    {
269
        return $this->lvl;
270
    }
271
272
    public function isTemplate(): bool
273
    {
274
        return $this->isTemplate;
275
    }
276
277
    public function setIsTemplate(bool $isTemplate): PortfolioComment
278
    {
279
        $this->isTemplate = $isTemplate;
280
281
        return $this;
282
    }
283
284
    public function getVisibility(): int
285
    {
286
        return $this->visibility;
287
    }
288
289
    public function setVisibility(int $visibility): PortfolioComment
290
    {
291
        $this->visibility = $visibility;
292
293
        return $this;
294
    }
295
}
296