1
|
|
|
<?php |
2
|
|
|
namespace DERHANSEN\SfEventMgt\Domain\Model\Registration; |
3
|
|
|
|
4
|
|
|
/* |
5
|
|
|
* This file is part of the TYPO3 CMS project. |
6
|
|
|
* |
7
|
|
|
* It is free software; you can redistribute it and/or modify it under |
8
|
|
|
* the terms of the GNU General Public License, either version 2 |
9
|
|
|
* of the License, or any later version. |
10
|
|
|
* |
11
|
|
|
* For the full copyright and license information, please read the |
12
|
|
|
* LICENSE.txt file that was distributed with this source code. |
13
|
|
|
* |
14
|
|
|
* The TYPO3 project - inspiring people to share! |
15
|
|
|
*/ |
16
|
|
|
|
17
|
|
|
use DERHANSEN\SfEventMgt\Domain\Model\Registration; |
18
|
|
|
use DERHANSEN\SfEventMgt\Utility\ArrayUtility; |
19
|
|
|
use DERHANSEN\SfEventMgt\Utility\FieldValueType; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Answer |
23
|
|
|
* |
24
|
|
|
* @author Torben Hansen <[email protected]> |
25
|
|
|
*/ |
26
|
|
|
class FieldValue extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* Value |
30
|
|
|
* |
31
|
|
|
* @var string |
32
|
|
|
*/ |
33
|
|
|
protected $value = ''; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* The type of the value |
37
|
|
|
* |
38
|
|
|
* @var int |
39
|
|
|
*/ |
40
|
|
|
protected $valueType = FieldValueType::TYPE_TEXT; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Field |
44
|
|
|
* |
45
|
|
|
* @var \DERHANSEN\SfEventMgt\Domain\Model\Registration\Field |
46
|
|
|
*/ |
47
|
|
|
protected $field = null; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Registration |
51
|
|
|
* |
52
|
|
|
* @var Registration |
53
|
|
|
*/ |
54
|
|
|
protected $registration = null; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Returns value depending on the valueType |
58
|
|
|
* |
59
|
|
|
* @return string|array |
60
|
|
|
*/ |
61
|
|
|
public function getValue() |
62
|
|
|
{ |
63
|
|
|
$value = $this->value; |
64
|
|
|
if ($this->getField()->getValueType() === FieldValueType::TYPE_ARRAY && ArrayUtility::isJsonArray($value)) { |
65
|
|
|
$value = json_decode($value, true); |
66
|
|
|
} |
67
|
|
|
return $value; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Sets value |
72
|
|
|
* |
73
|
|
|
* @param string $value |
74
|
|
|
* @return void |
75
|
|
|
*/ |
76
|
|
|
public function setValue($value) |
77
|
|
|
{ |
78
|
|
|
$this->value = $value; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Returns field |
83
|
|
|
* |
84
|
|
|
* @return \DERHANSEN\SfEventMgt\Domain\Model\Registration\Field |
85
|
|
|
*/ |
86
|
|
|
public function getField() |
87
|
|
|
{ |
88
|
|
|
return $this->field; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Sets field |
93
|
|
|
* |
94
|
|
|
* @param \DERHANSEN\SfEventMgt\Domain\Model\Registration\Field $field |
95
|
|
|
* @return void |
96
|
|
|
*/ |
97
|
|
|
public function setField($field) |
98
|
|
|
{ |
99
|
|
|
$this->field = $field; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Returns registration |
104
|
|
|
* |
105
|
|
|
* @return Registration |
106
|
|
|
*/ |
107
|
|
|
public function getRegistration() |
108
|
|
|
{ |
109
|
|
|
return $this->registration; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* Sets registration |
114
|
|
|
* |
115
|
|
|
* @param Registration $registration |
116
|
|
|
* @return void |
117
|
|
|
*/ |
118
|
|
|
public function setRegistration($registration) |
119
|
|
|
{ |
120
|
|
|
$this->registration = $registration; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* Sets value type |
125
|
|
|
* |
126
|
|
|
* @return int |
127
|
|
|
*/ |
128
|
|
|
public function getValueType() |
129
|
|
|
{ |
130
|
|
|
return $this->valueType; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* Returns value type |
135
|
|
|
* |
136
|
|
|
* @param int $valueType |
137
|
|
|
*/ |
138
|
|
|
public function setValueType($valueType) |
139
|
|
|
{ |
140
|
|
|
$this->valueType = $valueType; |
141
|
|
|
} |
142
|
|
|
} |
143
|
|
|
|