Passed
Pull Request — master (#90)
by
unknown
02:11
created

DocumentFormField::setGndFieldUid()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
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
    public function getValue()
54
    {
55
        return $this->value;
56
    }
57
58
    public function setValue($value, $defaultValue = '')
59
    {
60
61
        $this->hasDefaultValue = !empty($defaultValue);
62
63
        if (empty($value)) {
64
            switch ($this->inputField) {
65
                case \EWW\Dpf\Domain\Model\MetadataObject::select:
66
                    if (!empty($defaultValue)) {
67
                        $this->value = $this->defaultInputOption;
68
                    } else {
69
                        $this->value = '';
70
                    }
71
                    break;
72
73
                case \EWW\Dpf\Domain\Model\MetadataObject::checkbox:
74
                    if (!empty($defaultValue)) {
75
                        $this->value = 'yes';
76
                    } else {
77
                        $this->value = '';
78
                    }
79
                    break;
80
81
                default:
82
                    $this->value = $defaultValue;
83
                    break;
84
            }
85
        } else {
86
            $this->value = $value;
87
        }
88
    }
89
90
    public function getInputField()
91
    {
92
        return $this->inputField;
93
    }
94
95
    public function setInputField($inputField)
96
    {
97
        $this->inputField = $inputField;
98
    }
99
100
    /**
101
     *
102
     * @return array
103
     */
104
    public function getInputOptions()
105
    {
106
        return $this->inputOptions;
107
    }
108
109
    /**
110
     *
111
     * @param \EWW\Dpf\Domain\Model\InputOptionList $inputOptionList
112
     */
113
    public function setInputOptions(\EWW\Dpf\Domain\Model\InputOptionList $inputOptionList = null)
114
    {
115
116
        $this->inputOptions = array();
117
118
        if ($inputOptionList) {
119
            $this->inputOptions[''] = '';
120
            foreach ($inputOptionList->getInputOptions() as $option => $label) {
121
                $this->inputOptions[$option] = $label;
122
            }
123
124
            $this->defaultInputOption = trim($inputOptionList->getDefaultValue());
125
        }
126
127
    }
128
129
    /**
130
     * Returns the fillOutService
131
     *
132
     * @return string $fillOutService
133
     */
134
    public function getFillOutService()
135
    {
136
        return $this->fillOutService;
137
    }
138
139
    /**
140
     * Sets the fillOutService
141
     *
142
     * @param string $fillOutService
143
     * @return void
144
     */
145
    public function setFillOutService($fillOutService)
146
    {
147
        $this->fillOutService = $fillOutService;
148
    }
149
150
    /**
151
     * Returns the consent
152
     *
153
     * @return boolean $consent
154
     */
155
    public function getConsent()
156
    {
157
        return $this->consent;
158
    }
159
160
    /**
161
     * Sets the consent
162
     *
163
     * @param boolean $consent
164
     * @return void
165
     */
166
    public function setConsent($consent)
167
    {
168
        $this->consent = $consent;
169
    }
170
171
    public function getHasDefaultValue()
172
    {
173
        return $this->hasDefaultValue;
174
    }
175
176
    public function getValidation()
177
    {
178
        return $this->validation;
179
    }
180
181
    public function setValidation($validation)
182
    {
183
        $this->validation = $validation;
184
    }
185
186
    /**
187
     * Gets the data type of the field, e.g. DATE
188
     *
189
     * @return string
190
     */
191
    public function getDataType()
192
    {
193
        return $this->dataType;
194
    }
195
196
    /**
197
     * Sets the data type of the field, e.g. DATE
198
     *
199
     * @param string $dataType
200
     * @return void
201
     */
202
    public function setDataType($dataType)
203
    {
204
        $this->dataType = $dataType;
205
    }
206
207
    /**
208
     * Gets the uid of the field which is
209
     * linked with the gnd field
210
     *
211
     * @return int
212
     */
213
    public function getGndFieldUid() {
214
        return $this->gndFieldUid;
215
    }
216
217
    /**
218
     * Sets the uid of the field which is
219
     * linked with the gnd field
220
     *
221
     * @param int $fieldId
222
     * @return void
223
     */
224
    public function setGndFieldUid($fieldId) {
225
        $this->gndFieldUid = $fieldId;
226
    }
227
}
228