Completed
Pull Request — 1.11.x (#1163)
by José
71:40 queued 25:11
created

Skill::setProfile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
/* For licensing terms, see /license.txt */
4
5
/**
6
 * Skill Entity
7
 *
8
 * @package chamilo.skill
9
 */
10
11
namespace Chamilo\CoreBundle\Entity;
12
13
use Doctrine\ORM\Mapping as ORM;
14
15
/**
16
 * Skill
17
 *
18
 * @ORM\Table(name="skill")
19
 * @ORM\Entity(repositoryClass="Chamilo\CoreBundle\Entity\Repository\SkillRepository")
20
 */
21
class Skill
22
{
23
    const STATUS_DISABLED = 0;
24
    const STATUS_ENABLED = 1;
25
26
    /**
27
     * @var string
28
     *
29
     * @ORM\Column(name="name", type="string", length=255, nullable=false)
30
     */
31
    private $name;
32
33
    /**
34
     * @var string
35
     *
36
     * @ORM\Column(name="short_code", type="string", length=100, nullable=false)
37
     */
38
    private $shortCode;
39
40
    /**
41
     * @var string
42
     *
43
     * @ORM\Column(name="description", type="text", nullable=false)
44
     */
45
    private $description;
46
47
    /**
48
     * @var integer
49
     *
50
     * @ORM\Column(name="access_url_id", type="integer", nullable=false)
51
     */
52
    private $accessUrlId;
53
54
    /**
55
     * @var string
56
     *
57
     * @ORM\Column(name="icon", type="string", length=255, nullable=false)
58
     */
59
    private $icon;
60
61
    /**
62
     * @var string
63
     *
64
     * @ORM\Column(name="criteria", type="text", nullable=true)
65
     */
66
    private $criteria;
67
68
    /**
69
     * @var integer
70
     *
71
     * @ORM\Column(name="status", type="integer", nullable=false, options={"default": 1})
72
     */
73
    private $status;
74
75
    /**
76
     * @var \DateTime
77
     *
78
     * @ORM\Column(name="updated_at", type="datetime", nullable=false)
79
     */
80
    private $updatedAt;
81
82
    /**
83
     * @var integer
84
     *
85
     * @ORM\Column(name="id", type="integer")
86
     * @ORM\Id
87
     * @ORM\GeneratedValue(strategy="IDENTITY")
88
     */
89
    private $id;
90
91
    /**
92
     * @ORM\ManyToOne(targetEntity="Chamilo\SkillBundle\Entity\Profile", inversedBy="skills")
93
     * @ORM\JoinColumn(name="profile_id", referencedColumnName="id")
94
     **/
95
    protected $profile;
96
97
    /**
98
     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\SkillRelUser", mappedBy="skill", cascade={"persist"})
99
     */
100
    protected $issuedSkills;
101
102
    /**
103
     * @return string
104
     */
105
    public function __toString()
106
    {
107
        return (string) $this->getName();
108
    }
109
110
    /**
111
     * Set name
112
     *
113
     * @param string $name
114
     * @return Skill
115
     */
116
    public function setName($name)
117
    {
118
        $this->name = $name;
119
120
        return $this;
121
    }
122
123
    /**
124
     * Get name
125
     *
126
     * @return string
127
     */
128
    public function getName()
129
    {
130
        return $this->name;
131
    }
132
133
    /**
134
     * Set shortCode
135
     *
136
     * @param string $shortCode
137
     * @return Skill
138
     */
139
    public function setShortCode($shortCode)
140
    {
141
        $this->shortCode = $shortCode;
142
143
        return $this;
144
    }
145
146
    /**
147
     * Get shortCode
148
     *
149
     * @return string
150
     */
151
    public function getShortCode()
152
    {
153
        return $this->shortCode;
154
    }
155
156
    /**
157
     * Set description
158
     *
159
     * @param string $description
160
     * @return Skill
161
     */
162
    public function setDescription($description)
163
    {
164
        $this->description = $description;
165
166
        return $this;
167
    }
168
169
    /**
170
     * Get description
171
     *
172
     * @return string
173
     */
174
    public function getDescription()
175
    {
176
        return $this->description;
177
    }
178
179
    /**
180
     * Set accessUrlId
181
     *
182
     * @param integer $accessUrlId
183
     * @return Skill
184
     */
185
    public function setAccessUrlId($accessUrlId)
186
    {
187
        $this->accessUrlId = $accessUrlId;
188
189
        return $this;
190
    }
191
192
    /**
193
     * Get accessUrlId
194
     *
195
     * @return integer
196
     */
197
    public function getAccessUrlId()
198
    {
199
        return $this->accessUrlId;
200
    }
201
202
    /**
203
     * Set icon
204
     *
205
     * @param string $icon
206
     * @return Skill
207
     */
208
    public function setIcon($icon)
209
    {
210
        $this->icon = $icon;
211
212
        return $this;
213
    }
214
215
    /**
216
     * Get icon
217
     *
218
     * @return string
219
     */
220
    public function getIcon()
221
    {
222
        return $this->icon;
223
    }
224
225
    /**
226
     * Get the icon (badge image) URL
227
     * @param boolean $getSmall Optional. Allow get the small image
228
     * @return string
229
     */
230
    public function getWebIconPath($getSmall = false)
231
    {
232
        if ($getSmall) {
233 View Code Duplication
            if (empty($this->icon)) {
234
                return \Display::return_icon('badges-default.png', null, null, ICON_SIZE_BIG, null, true);
235
            }
236
237
            return api_get_path(WEB_UPLOAD_PATH) . 'badges/' . sha1($this->name) . '-small.png';
238
        }
239
240 View Code Duplication
        if (empty($this->icon)) {
241
            return \Display::return_icon('badges-default.png', null, null, ICON_SIZE_HUGE, null, true);
242
        }
243
244
        return api_get_path(WEB_UPLOAD_PATH) . "badges/{$this->icon}";
245
    }
246
247
    /**
248
     * Set criteria
249
     *
250
     * @param string $criteria
251
     * @return Skill
252
     */
253
    public function setCriteria($criteria)
254
    {
255
        $this->criteria = $criteria;
256
257
        return $this;
258
    }
259
260
    /**
261
     * Get criteria
262
     *
263
     * @return string
264
     */
265
    public function getCriteria()
266
    {
267
        return $this->criteria;
268
    }
269
270
    /**
271
     * Set status
272
     * @param integer $status
273
     * @return \Chamilo\CoreBundle\Entity\Skill
274
     */
275
    public function setStatus($status)
276
    {
277
        $this->status = $status;
278
279
        return $this;
280
    }
281
282
    /**
283
     * Get status
284
     * @return integer
285
     */
286
    public function getStatus()
287
    {
288
        return $this->status;
289
    }
290
291
    /**
292
     * Set updatedAt
293
     * @param \DateTime $updatedAt The update datetime
294
     * @return \Chamilo\CoreBundle\Entity\Skill
295
     */
296
    public function setUpdatedAt(\DateTime $updatedAt)
297
    {
298
        $this->updatedAt = $updatedAt;
299
300
        return $this;
301
    }
302
303
    /**
304
     * Get updatedAt
305
     * @return \DateTime
306
     */
307
    public function getUpdatedAt()
308
    {
309
        return $this->updatedAt;
310
    }
311
312
    /**
313
     * Get id
314
     *
315
     * @return integer
316
     */
317
    public function getId()
318
    {
319
        return $this->id;
320
    }
321
322
    /**
323
     * @return Profile
324
     */
325
    public function getProfile()
326
    {
327
        return $this->profile;
328
    }
329
330
    /**
331
     * @param Profile $profile
332
     *
333
     * @return Skill
334
     */
335
    public function setProfile($profile)
336
    {
337
        $this->profile = $profile;
338
339
        return $this;
340
    }
341
342
    /**
343
     * Get issuedSkills
344
     * @return ArrayCollection
345
     */
346
    public function getIssuedSkills()
347
    {
348
        return $this->issuedSkills;
349
    }
350
351
}
352