Passed
Push — master ( 6d3284...3ff5ba )
by Julito
13:22 queued 02:03
created

ExtraField::setDescription()   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
/* For licensing terms, see /license.txt */
3
4
namespace Chamilo\CoreBundle\Entity;
5
6
use Doctrine\ORM\Mapping as ORM;
7
use Gedmo\Mapping\Annotation as Gedmo;
8
9
/**
10
 * Class ExtraField.
11
 *
12
 * @ORM\Entity
13
 * @ORM\Table(name="extra_field")
14
 *
15
 * @ORM\MappedSuperclass
16
 */
17
class ExtraField // extends BaseAttribute
18
{
19
    public const USER_FIELD_TYPE = 1;
20
    public const COURSE_FIELD_TYPE = 2;
21
    public const SESSION_FIELD_TYPE = 3;
22
    public const QUESTION_FIELD_TYPE = 4;
23
    public const CALENDAR_FIELD_TYPE = 5;
24
    public const LP_FIELD_TYPE = 6;
25
    public const LP_ITEM_FIELD_TYPE = 7;
26
    public const SKILL_FIELD_TYPE = 8;
27
    public const WORK_FIELD_TYPE = 9;
28
    public const CAREER_FIELD_TYPE = 10;
29
    public const USER_CERTIFICATE = 11;
30
    public const SURVEY_FIELD_TYPE = 12;
31
    public const SCHEDULED_ANNOUNCEMENT = 13;
32
33
    /**
34
     * @var int
35
     *
36
     * @ORM\Column(name="id", type="integer", nullable=false, unique=false)
37
     * @ORM\Id
38
     * @ORM\GeneratedValue
39
     */
40
    protected $id;
41
42
    /**
43
     * @var int
44
     *
45
     * @ORM\Column(name="extra_field_type", type="integer", nullable=false, unique=false)
46
     */
47
    protected $extraFieldType;
48
49
    /**
50
     * @var int
51
     *
52
     * @ORM\Column(name="field_type", type="integer", nullable=false, unique=false)
53
     */
54
    protected $fieldType;
55
56
    /**
57
     * @var string
58
     *
59
     * @ORM\Column(name="variable", type="string", length=255, nullable=false, unique=false)
60
     */
61
    protected $variable;
62
63
    /**
64
     * @var string
65
     *
66
     * @ORM\Column(name="description", type="text", nullable=true)
67
     */
68
    protected $description;
69
70
    /**
71
     * @var string
72
     *
73
     * @ORM\Column(name="display_text", type="string", length=255, nullable=true, unique=false)
74
     */
75
    protected $displayText;
76
77
    /**
78
     * @var string
79
     *
80
     * @ORM\Column(name="default_value", type="text", nullable=true, unique=false)
81
     */
82
    protected $defaultValue;
83
84
    /**
85
     * @var int
86
     *
87
     * @ORM\Column(name="field_order", type="integer", nullable=true, unique=false)
88
     */
89
    protected $fieldOrder;
90
91
    /**
92
     * @var bool
93
     *
94
     * @ORM\Column(name="visible_to_self", type="boolean", nullable=true, unique=false)
95
     */
96
    protected $visibleToSelf;
97
98
    /**
99
     * @var bool
100
     *
101
     * @ORM\Column(name="visible_to_others", type="boolean", nullable=true, unique=false)
102
     */
103
    protected $visibleToOthers;
104
105
    /**
106
     * @var bool
107
     *
108
     * @ORM\Column(name="changeable", type="boolean", nullable=true, unique=false)
109
     */
110
    protected $changeable;
111
112
    /**
113
     * @var bool
114
     *
115
     * @ORM\Column(name="filter", type="boolean", nullable=true, unique=false)
116
     */
117
    protected $filter;
118
119
    /**
120
     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\ExtraFieldOptions", mappedBy="field")
121
     */
122
    protected $options;
123
124
    /**
125
     * @var \DateTime
126
     *
127
     * @Gedmo\Timestampable(on="create")
128
     * @ORM\Column(name="created_at", type="datetime")
129
     */
130
    protected $createdAt;
131
132
    /**
133
     * ExtraField constructor.
134
     */
135
    public function __construct()
136
    {
137
        //parent::__construct();
138
        $this->visibleToOthers = false;
139
        $this->visibleToSelf = false;
140
    }
141
142
    /**
143
     * Get id.
144
     *
145
     * @return int
146
     */
147
    public function getId()
148
    {
149
        return $this->id;
150
    }
151
152
    /**
153
     * @return int
154
     */
155
    public function getExtraFieldType()
156
    {
157
        return $this->extraFieldType;
158
    }
159
160
    /**
161
     * @param int $extraFieldType
162
     *
163
     * @return $this
164
     */
165
    public function setExtraFieldType($extraFieldType)
166
    {
167
        $this->extraFieldType = $extraFieldType;
168
169
        return $this;
170
    }
171
172
    /**
173
     * @return int
174
     */
175
    public function getFieldType()
176
    {
177
        return $this->fieldType;
178
    }
179
180
    /**
181
     * @param int $fieldType
182
     *
183
     * @return $this
184
     */
185
    public function setFieldType($fieldType)
186
    {
187
        $this->fieldType = $fieldType;
188
189
        return $this;
190
    }
191
192
    /**
193
     * @return string
194
     */
195
    public function getVariable()
196
    {
197
        return $this->variable;
198
    }
199
200
    /**
201
     * @param string $variable
202
     *
203
     * @return $this
204
     */
205
    public function setVariable($variable)
206
    {
207
        $this->variable = $variable;
208
209
        return $this;
210
    }
211
212
    /**
213
     * @param bool $translated Optional. Whether translate the display text
214
     *
215
     * @return string
216
     */
217
    public function getDisplayText($translated = true)
218
    {
219
        if ($translated) {
220
            return \ExtraField::translateDisplayName($this->variable, $this->displayText);
221
        }
222
223
        return $this->displayText;
224
    }
225
226
    /**
227
     * @param string $displayText
228
     *
229
     * @return $this
230
     */
231
    public function setDisplayText($displayText)
232
    {
233
        $this->displayText = $displayText;
234
235
        return $this;
236
    }
237
238
    /**
239
     * @return string
240
     */
241
    public function getDefaultValue()
242
    {
243
        return $this->defaultValue;
244
    }
245
246
    /**
247
     * @param string $defaultValue
248
     *
249
     * @return $this
250
     */
251
    public function setDefaultValue($defaultValue)
252
    {
253
        $this->defaultValue = $defaultValue;
254
255
        return $this;
256
    }
257
258
    /**
259
     * @return int
260
     */
261
    public function getFieldOrder()
262
    {
263
        return $this->fieldOrder;
264
    }
265
266
    /**
267
     * @param int $fieldOrder
268
     *
269
     * @return $this
270
     */
271
    public function setFieldOrder($fieldOrder)
272
    {
273
        $this->fieldOrder = $fieldOrder;
274
275
        return $this;
276
    }
277
278
    /**
279
     * @return bool
280
     */
281
    public function isChangeable()
282
    {
283
        return $this->changeable;
284
    }
285
286
    /**
287
     * @param bool $changeable
288
     *
289
     * @return $this
290
     */
291
    public function setChangeable($changeable)
292
    {
293
        $this->changeable = $changeable;
294
295
        return $this;
296
    }
297
298
    /**
299
     * @return bool
300
     */
301
    public function isFilter()
302
    {
303
        return $this->filter;
304
    }
305
306
    /**
307
     * @param bool $filter
308
     *
309
     * @return $this
310
     */
311
    public function setFilter($filter)
312
    {
313
        $this->filter = $filter;
314
315
        return $this;
316
    }
317
318
    /**
319
     * @return bool
320
     */
321
    public function isVisibleToSelf()
322
    {
323
        return $this->visibleToSelf;
324
    }
325
326
    /**
327
     * @param bool $visibleToSelf
328
     *
329
     * @return ExtraField
330
     */
331
    public function setVisibleToSelf($visibleToSelf)
332
    {
333
        $this->visibleToSelf = $visibleToSelf;
334
335
        return $this;
336
    }
337
338
    /**
339
     * @return bool
340
     */
341
    public function isVisibleToOthers()
342
    {
343
        return $this->visibleToOthers;
344
    }
345
346
    /**
347
     * @param bool $visibleToOthers
348
     *
349
     * @return ExtraField
350
     */
351
    public function setVisibleToOthers($visibleToOthers)
352
    {
353
        $this->visibleToOthers = $visibleToOthers;
354
355
        return $this;
356
    }
357
358
    /**
359
     * @return string
360
     */
361
    public function getDescription(): string
362
    {
363
        return $this->description;
364
    }
365
366
    /**
367
     * @param string $description
368
     *
369
     * @return ExtraField
370
     */
371
    public function setDescription(string $description): ExtraField
372
    {
373
        $this->description = $description;
374
375
        return $this;
376
    }
377
378
    /**
379
     * @return string
380
     */
381
    public function getTypeToString(): string
382
    {
383
        switch ($this->type) {
0 ignored issues
show
Bug Best Practice introduced by
The property type does not exist on Chamilo\CoreBundle\Entity\ExtraField. Did you maybe forget to declare it?
Loading history...
384
            case \ExtraField::FIELD_TYPE_TEXT:
385
            case \ExtraField::FIELD_TYPE_TEXTAREA:
386
                return 'text';
387
            case \ExtraField::FIELD_TYPE_RADIO:
388
            case \ExtraField::FIELD_TYPE_SELECT:
389
                return 'choice';
390
            default:
391
                return 'text';
392
        }
393
    }
394
}
395