Passed
Push — master ( 748ce8...32285e )
by Julito
07:34
created

CLink::setCategory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
/* For licensing terms, see /license.txt */
4
5
namespace Chamilo\CourseBundle\Entity;
6
7
use APY\DataGridBundle\Grid\Mapping as GRID;
8
use Chamilo\CoreBundle\Entity\Resource\AbstractResource;
9
use Chamilo\CoreBundle\Entity\Resource\ResourceInterface;
10
use Doctrine\ORM\Mapping as ORM;
11
12
/**
13
 * CLink.
14
 *
15
 * @ORM\Table(
16
 *  name="c_link",
17
 *  indexes={
18
 *      @ORM\Index(name="course", columns={"c_id"}),
19
 *      @ORM\Index(name="session_id", columns={"session_id"})
20
 *  }
21
 * )
22
 * @ORM\Entity
23
 * @GRID\Source(columns="iid, title, resourceNode.createdAt", filterable=false, groups={"resource"})
24
 */
25
class CLink extends AbstractResource implements ResourceInterface
26
{
27
    /**
28
     * @var int
29
     *
30
     * @ORM\Column(name="iid", type="integer")
31
     * @ORM\Id
32
     * @ORM\GeneratedValue
33
     */
34
    protected $iid;
35
36
    /**
37
     * @var int
38
     *
39
     * @ORM\Column(name="c_id", type="integer")
40
     */
41
    protected $cId;
42
43
    /**
44
     * @var int
45
     *
46
     * @ORM\Column(name="id", type="integer", nullable=true)
47
     */
48
    protected $id;
49
50
    /**
51
     * @var string
52
     *
53
     * @ORM\Column(name="url", type="text", nullable=false)
54
     */
55
    protected $url;
56
57
    /**
58
     * @var string
59
     *
60
     * @ORM\Column(name="title", type="string", length=150, nullable=true)
61
     */
62
    protected $title;
63
64
    /**
65
     * @var string
66
     *
67
     * @ORM\Column(name="description", type="text", nullable=true)
68
     */
69
    protected $description;
70
71
    /**
72
     * @var CLinkCategory|null
73
     *
74
     * @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CLinkCategory", inversedBy="links")
75
     * @ORM\JoinColumn(name="category_id", referencedColumnName="iid")
76
     */
77
    protected $category;
78
79
    /**
80
     * @var int
81
     *
82
     * @ORM\Column(name="display_order", type="integer", nullable=false)
83
     */
84
    protected $displayOrder;
85
86
    /**
87
     * @var string
88
     *
89
     * @ORM\Column(name="on_homepage", type="string", length=10, nullable=false)
90
     */
91
    protected $onHomepage;
92
93
    /**
94
     * @var string
95
     *
96
     * @ORM\Column(name="target", type="string", length=10, nullable=true)
97
     */
98
    protected $target;
99
100
    /**
101
     * @var int
102
     *
103
     * @ORM\Column(name="session_id", type="integer", nullable=true)
104
     */
105
    protected $sessionId;
106
107
    public function __construct()
108
    {
109
        $this->displayOrder = 0;
110
    }
111
112
    public function __toString(): string
113
    {
114
        return $this->getTitle();
115
    }
116
117
    /**
118
     * Set url.
119
     *
120
     * @param string $url
121
     *
122
     * @return CLink
123
     */
124
    public function setUrl($url)
125
    {
126
        $this->url = $url;
127
128
        return $this;
129
    }
130
131
    /**
132
     * Get url.
133
     *
134
     * @return string
135
     */
136
    public function getUrl()
137
    {
138
        return $this->url;
139
    }
140
141
    /**
142
     * Set title.
143
     *
144
     * @param string $title
145
     *
146
     * @return CLink
147
     */
148
    public function setTitle($title)
149
    {
150
        $this->title = $title;
151
152
        return $this;
153
    }
154
155
    /**
156
     * Get title.
157
     *
158
     * @return string
159
     */
160
    public function getTitle()
161
    {
162
        return (string) $this->title;
163
    }
164
165
    /**
166
     * Set description.
167
     *
168
     * @param string $description
169
     *
170
     * @return CLink
171
     */
172
    public function setDescription($description)
173
    {
174
        $this->description = $description;
175
176
        return $this;
177
    }
178
179
    /**
180
     * Get description.
181
     *
182
     * @return string
183
     */
184
    public function getDescription()
185
    {
186
        return $this->description;
187
    }
188
189
    /**
190
     * Set displayOrder.
191
     *
192
     * @param int $displayOrder
193
     *
194
     * @return CLink
195
     */
196
    public function setDisplayOrder($displayOrder)
197
    {
198
        $this->displayOrder = $displayOrder;
199
200
        return $this;
201
    }
202
203
    /**
204
     * Get displayOrder.
205
     *
206
     * @return int
207
     */
208
    public function getDisplayOrder()
209
    {
210
        return $this->displayOrder;
211
    }
212
213
    /**
214
     * Set onHomepage.
215
     *
216
     * @param string $onHomepage
217
     *
218
     * @return CLink
219
     */
220
    public function setOnHomepage($onHomepage)
221
    {
222
        $this->onHomepage = $onHomepage;
223
224
        return $this;
225
    }
226
227
    /**
228
     * Get onHomepage.
229
     *
230
     * @return string
231
     */
232
    public function getOnHomepage()
233
    {
234
        return $this->onHomepage;
235
    }
236
237
    /**
238
     * Set target.
239
     *
240
     * @param string $target
241
     *
242
     * @return CLink
243
     */
244
    public function setTarget($target)
245
    {
246
        $this->target = $target;
247
248
        return $this;
249
    }
250
251
    /**
252
     * Get target.
253
     *
254
     * @return string
255
     */
256
    public function getTarget()
257
    {
258
        return $this->target;
259
    }
260
261
    /**
262
     * Set sessionId.
263
     *
264
     * @param int $sessionId
265
     *
266
     * @return CLink
267
     */
268
    public function setSessionId($sessionId)
269
    {
270
        $this->sessionId = $sessionId;
271
272
        return $this;
273
    }
274
275
    /**
276
     * Get sessionId.
277
     *
278
     * @return int
279
     */
280
    public function getSessionId()
281
    {
282
        return $this->sessionId;
283
    }
284
285
    /**
286
     * Set id.
287
     *
288
     * @param int $id
289
     *
290
     * @return CLink
291
     */
292
    public function setId($id)
293
    {
294
        $this->id = $id;
295
296
        return $this;
297
    }
298
299
    /**
300
     * Get id.
301
     *
302
     * @return int
303
     */
304
    public function getId()
305
    {
306
        return $this->id;
307
    }
308
309
    public function getIid(): int
310
    {
311
        return $this->iid;
312
    }
313
314
    public function setIid(int $iid): self
315
    {
316
        $this->iid = $iid;
317
318
        return $this;
319
    }
320
321
    /**
322
     * Set cId.
323
     *
324
     * @param int $cId
325
     *
326
     * @return CLink
327
     */
328
    public function setCId($cId)
329
    {
330
        $this->cId = $cId;
331
332
        return $this;
333
    }
334
335
    /**
336
     * Get cId.
337
     *
338
     * @return int
339
     */
340
    public function getCId()
341
    {
342
        return $this->cId;
343
    }
344
345
    public function getCategory(): ?CLinkCategory
346
    {
347
        return $this->category;
348
    }
349
350
    public function setCategory(?CLinkCategory $category): self
351
    {
352
        $this->category = $category;
353
354
        return $this;
355
    }
356
357
    /**
358
     * Resource identifier.
359
     */
360
    public function getResourceIdentifier(): int
361
    {
362
        return $this->iid;
363
    }
364
365
    public function getResourceName(): string
366
    {
367
        return $this->getTitle();
368
    }
369
}
370