Completed
Push — master ( 40658a...92c813 )
by Julito
12:23
created

ExtraField::getHelperText()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
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
    public const TERMS_AND_CONDITION_TYPE = 14;
33
    public const FORUM_CATEGORY_TYPE = 15;
34
    public const FORUM_POST_TYPE = 16;
35
    public const EXERCISE_FIELD_TYPE = 17;
36
37
    /**
38
     * @var int
39
     *
40
     * @ORM\Column(name="id", type="integer", nullable=false, unique=false)
41
     * @ORM\Id
42
     * @ORM\GeneratedValue
43
     */
44
    protected $id;
45
46
    /**
47
     * @var int
48
     *
49
     * @ORM\Column(name="extra_field_type", type="integer", nullable=false, unique=false)
50
     */
51
    protected $extraFieldType;
52
53
    /**
54
     * @var int
55
     *
56
     * @ORM\Column(name="field_type", type="integer", nullable=false, unique=false)
57
     */
58
    protected $fieldType;
59
60
    /**
61
     * @var string
62
     *
63
     * @ORM\Column(name="variable", type="string", length=255, nullable=false, unique=false)
64
     */
65
    protected $variable;
66
67
    /**
68
     * @var string
69
     *
70
     * @ORM\Column(name="description", type="text", nullable=true)
71
     */
72
    protected $description;
73
74
    /**
75
     * @var string
76
     *
77
     * @ORM\Column(name="display_text", type="string", length=255, nullable=true, unique=false)
78
     */
79
    protected $displayText;
80
81
    /**
82
     * @var string
83
     *
84
     * @ORM\Column(name="helper_text", type="text", nullable=true, unique=false)
85
     */
86
    protected $helperText;
87
88
    /**
89
     * @var string
90
     *
91
     * @ORM\Column(name="default_value", type="text", nullable=true, unique=false)
92
     */
93
    protected $defaultValue;
94
95
    /**
96
     * @var int
97
     *
98
     * @ORM\Column(name="field_order", type="integer", nullable=true, unique=false)
99
     */
100
    protected $fieldOrder;
101
102
    /**
103
     * @var bool
104
     *
105
     * @ORM\Column(name="visible_to_self", type="boolean", nullable=true, unique=false)
106
     */
107
    protected $visibleToSelf;
108
109
    /**
110
     * @var bool
111
     *
112
     * @ORM\Column(name="visible_to_others", type="boolean", nullable=true, unique=false)
113
     */
114
    protected $visibleToOthers;
115
116
    /**
117
     * @var bool
118
     *
119
     * @ORM\Column(name="changeable", type="boolean", nullable=true, unique=false)
120
     */
121
    protected $changeable;
122
123
    /**
124
     * @var bool
125
     *
126
     * @ORM\Column(name="filter", type="boolean", nullable=true, unique=false)
127
     */
128
    protected $filter;
129
130
    /**
131
     * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\ExtraFieldOptions", mappedBy="field")
132
     */
133
    protected $options;
134
135
    /**
136
     * @var \DateTime
137
     *
138
     * @Gedmo\Timestampable(on="create")
139
     * @ORM\Column(name="created_at", type="datetime")
140
     */
141
    protected $createdAt;
142
143
    /**
144
     * ExtraField constructor.
145
     */
146
    public function __construct()
147
    {
148
        //parent::__construct();
149
        $this->visibleToOthers = false;
150
        $this->visibleToSelf = false;
151
    }
152
153
    /**
154
     * Get id.
155
     *
156
     * @return int
157
     */
158
    public function getId()
159
    {
160
        return $this->id;
161
    }
162
163
    /**
164
     * @return int
165
     */
166
    public function getExtraFieldType()
167
    {
168
        return $this->extraFieldType;
169
    }
170
171
    /**
172
     * @param int $extraFieldType
173
     *
174
     * @return $this
175
     */
176
    public function setExtraFieldType($extraFieldType)
177
    {
178
        $this->extraFieldType = $extraFieldType;
179
180
        return $this;
181
    }
182
183
    /**
184
     * @return int
185
     */
186
    public function getFieldType()
187
    {
188
        return $this->fieldType;
189
    }
190
191
    /**
192
     * @param int $fieldType
193
     *
194
     * @return $this
195
     */
196
    public function setFieldType($fieldType)
197
    {
198
        $this->fieldType = $fieldType;
199
200
        return $this;
201
    }
202
203
    /**
204
     * @return string
205
     */
206
    public function getVariable()
207
    {
208
        return $this->variable;
209
    }
210
211
    /**
212
     * @param string $variable
213
     *
214
     * @return $this
215
     */
216
    public function setVariable($variable)
217
    {
218
        $this->variable = $variable;
219
220
        return $this;
221
    }
222
223
    /**
224
     * @param bool $translated Optional. Whether translate the display text
225
     *
226
     * @return string
227
     */
228
    public function getDisplayText($translated = true)
229
    {
230
        if ($translated) {
231
            return \ExtraField::translateDisplayName($this->variable, $this->displayText);
232
        }
233
234
        return $this->displayText;
235
    }
236
237
    /**
238
     * @param string $displayText
239
     *
240
     * @return $this
241
     */
242
    public function setDisplayText($displayText)
243
    {
244
        $this->displayText = $displayText;
245
246
        return $this;
247
    }
248
249
    /**
250
     * @return string
251
     */
252
    public function getDefaultValue()
253
    {
254
        return $this->defaultValue;
255
    }
256
257
    /**
258
     * @param string $defaultValue
259
     *
260
     * @return $this
261
     */
262
    public function setDefaultValue($defaultValue)
263
    {
264
        $this->defaultValue = $defaultValue;
265
266
        return $this;
267
    }
268
269
    /**
270
     * @return int
271
     */
272
    public function getFieldOrder()
273
    {
274
        return $this->fieldOrder;
275
    }
276
277
    /**
278
     * @param int $fieldOrder
279
     *
280
     * @return $this
281
     */
282
    public function setFieldOrder($fieldOrder)
283
    {
284
        $this->fieldOrder = $fieldOrder;
285
286
        return $this;
287
    }
288
289
    /**
290
     * @return bool
291
     */
292
    public function isChangeable()
293
    {
294
        return $this->changeable;
295
    }
296
297
    /**
298
     * @param bool $changeable
299
     *
300
     * @return $this
301
     */
302
    public function setChangeable($changeable)
303
    {
304
        $this->changeable = $changeable;
305
306
        return $this;
307
    }
308
309
    /**
310
     * @return bool
311
     */
312
    public function isFilter()
313
    {
314
        return $this->filter;
315
    }
316
317
    /**
318
     * @param bool $filter
319
     *
320
     * @return $this
321
     */
322
    public function setFilter($filter)
323
    {
324
        $this->filter = $filter;
325
326
        return $this;
327
    }
328
329
    /**
330
     * @return bool
331
     */
332
    public function isVisibleToSelf()
333
    {
334
        return $this->visibleToSelf;
335
    }
336
337
    /**
338
     * @param bool $visibleToSelf
339
     *
340
     * @return ExtraField
341
     */
342
    public function setVisibleToSelf($visibleToSelf)
343
    {
344
        $this->visibleToSelf = $visibleToSelf;
345
346
        return $this;
347
    }
348
349
    /**
350
     * @return bool
351
     */
352
    public function isVisibleToOthers()
353
    {
354
        return $this->visibleToOthers;
355
    }
356
357
    /**
358
     * @param bool $visibleToOthers
359
     *
360
     * @return ExtraField
361
     */
362
    public function setVisibleToOthers($visibleToOthers)
363
    {
364
        $this->visibleToOthers = $visibleToOthers;
365
366
        return $this;
367
    }
368
369
    public function getDescription(): string
370
    {
371
        return $this->description;
372
    }
373
374
    public function setDescription(string $description): ExtraField
375
    {
376
        $this->description = $description;
377
378
        return $this;
379
    }
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
    /**
396
     * @return string
397
     */
398
    public function getHelperText(): string
399
    {
400
        return $this->helperText;
401
    }
402
403
    /**
404
     * @param string $helperText
405
     *
406
     * @return ExtraField
407
     */
408
    public function setHelperText(string $helperText): ExtraField
409
    {
410
        $this->helperText = $helperText;
411
412
        return $this;
413
    }
414
}
415