Passed
Pull Request — master (#132)
by
unknown
15:02 queued 06:44
created

DocumentFormField   A

Complexity

Total Complexity 26

Size/Duplication

Total Lines 233
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 56
dl 0
loc 233
rs 10
c 0
b 0
f 0
wmc 26

19 Methods

Rating   Name   Duplication   Size   Complexity  
A getInputOptions() 0 3 1
B setValue() 0 29 6
A getHasDefaultValue() 0 3 1
A setDataType() 0 3 1
A setValidation() 0 3 1
A getInputField() 0 3 1
A getValue() 0 3 1
A setMaxInputLength() 0 2 1
A setInputField() 0 3 1
A setConsent() 0 3 1
A getFillOutService() 0 3 1
A getMaxInputLength() 0 2 1
A getConsent() 0 3 1
A getDataType() 0 3 1
A setFillOutService() 0 3 1
A getGndFieldUid() 0 2 1
A setGndFieldUid() 0 2 1
A getValidation() 0 3 1
A setInputOptions() 0 12 3
1
<?php
2
namespace EWW\Dpf\Domain\Model;
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
class DocumentFormField extends AbstractFormElement
18
{
19
20
    protected $value;
21
22
    protected $inputField;
23
24
    protected $selectOptions;
25
26
    protected $inputOptions;
27
28
    protected $fillOutService;
29
30
    protected $defaultInputOption;
31
32
    protected $hasDefaultValue = false;
33
34
    protected $validation;
35
36
    /**
37
     * @var string
38
     */
39
    protected $dataType;
40
41
    /**
42
     * @var int
43
     */
44
    protected $gndFieldUid;
45
46
    /**
47
     * consent
48
     *
49
     * @var boolean
50
     */
51
    protected $consent;
52
53
    /**
54
     * @var int
55
     */
56
    protected $maxInputLength;
57
58
59
    public function getValue()
60
    {
61
        return $this->value;
62
    }
63
64
    public function setValue($value, $defaultValue = '')
65
    {
66
67
        $this->hasDefaultValue = !empty($defaultValue);
68
69
        if (empty($value)) {
70
            switch ($this->inputField) {
71
                case \EWW\Dpf\Domain\Model\MetadataObject::select:
72
                    if (!empty($defaultValue)) {
73
                        $this->value = $this->defaultInputOption;
74
                    } else {
75
                        $this->value = '';
76
                    }
77
                    break;
78
79
                case \EWW\Dpf\Domain\Model\MetadataObject::checkbox:
80
                    if (!empty($defaultValue)) {
81
                        $this->value = 'yes';
82
                    } else {
83
                        $this->value = '';
84
                    }
85
                    break;
86
87
                default:
88
                    $this->value = $defaultValue;
89
                    break;
90
            }
91
        } else {
92
            $this->value = $value;
93
        }
94
    }
95
96
    public function getInputField()
97
    {
98
        return $this->inputField;
99
    }
100
101
    public function setInputField($inputField)
102
    {
103
        $this->inputField = $inputField;
104
    }
105
106
    /**
107
     *
108
     * @return array
109
     */
110
    public function getInputOptions()
111
    {
112
        return $this->inputOptions;
113
    }
114
115
    /**
116
     *
117
     * @param \EWW\Dpf\Domain\Model\InputOptionList $inputOptionList
118
     */
119
    public function setInputOptions(\EWW\Dpf\Domain\Model\InputOptionList $inputOptionList = null)
120
    {
121
122
        $this->inputOptions = array();
123
124
        if ($inputOptionList) {
125
            $this->inputOptions[''] = '';
126
            foreach ($inputOptionList->getInputOptions() as $option => $label) {
127
                $this->inputOptions[$option] = $label;
128
            }
129
130
            $this->defaultInputOption = trim($inputOptionList->getDefaultValue());
131
        }
132
133
    }
134
135
    /**
136
     * Returns the fillOutService
137
     *
138
     * @return string $fillOutService
139
     */
140
    public function getFillOutService()
141
    {
142
        return $this->fillOutService;
143
    }
144
145
    /**
146
     * Sets the fillOutService
147
     *
148
     * @param string $fillOutService
149
     * @return void
150
     */
151
    public function setFillOutService($fillOutService)
152
    {
153
        $this->fillOutService = $fillOutService;
154
    }
155
156
    /**
157
     * Returns the consent
158
     *
159
     * @return boolean $consent
160
     */
161
    public function getConsent()
162
    {
163
        return $this->consent;
164
    }
165
166
    /**
167
     * Sets the consent
168
     *
169
     * @param boolean $consent
170
     * @return void
171
     */
172
    public function setConsent($consent)
173
    {
174
        $this->consent = $consent;
175
    }
176
177
    public function getHasDefaultValue()
178
    {
179
        return $this->hasDefaultValue;
180
    }
181
182
    public function getValidation()
183
    {
184
        return $this->validation;
185
    }
186
187
    public function setValidation($validation)
188
    {
189
        $this->validation = $validation;
190
    }
191
192
    /**
193
     * Gets the data type of the field, e.g. DATE
194
     *
195
     * @return string
196
     */
197
    public function getDataType()
198
    {
199
        return $this->dataType;
200
    }
201
202
    /**
203
     * Sets the data type of the field, e.g. DATE
204
     *
205
     * @param string $dataType
206
     * @return void
207
     */
208
    public function setDataType($dataType)
209
    {
210
        $this->dataType = $dataType;
211
    }
212
213
    /**
214
     * Gets the uid of the field which is
215
     * linked with the gnd field
216
     *
217
     * @return int
218
     */
219
    public function getGndFieldUid() {
220
        return $this->gndFieldUid;
221
    }
222
223
    /**
224
     * Sets the uid of the field which is
225
     * linked with the gnd field
226
     *
227
     * @param int $fieldId
228
     * @return void
229
     */
230
    public function setGndFieldUid($fieldId) {
231
        $this->gndFieldUid = $fieldId;
232
    }
233
234
    /**
235
     * Gets the max length of characters for the input field.
236
     *
237
     * @return int
238
     */
239
    public function getMaxInputLength() {
240
        return $this->maxInputLength;
241
    }
242
243
    /**
244
     * Sets the max length of characters for the input field.
245
     *
246
     * @return int
247
     */
248
    public function setMaxInputLength($maxInputLength) {
249
        $this->maxInputLength = $maxInputLength;
250
    }
251
252
}
253