Passed
Pull Request — master (#90)
by
unknown
03:04
created

DocumentFormField::getValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
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
    protected $dataType;
37
38
    protected $gndFieldUid;
39
40
    /**
41
     * consent
42
     *
43
     * @var boolean
44
     */
45
    protected $consent;
46
47
    public function getValue()
48
    {
49
        return $this->value;
50
    }
51
52
    public function setValue($value, $defaultValue = '')
53
    {
54
55
        $this->hasDefaultValue = !empty($defaultValue);
56
57
        if (empty($value)) {
58
            switch ($this->inputField) {
59
                case \EWW\Dpf\Domain\Model\MetadataObject::select:
60
                    if (!empty($defaultValue)) {
61
                        $this->value = $this->defaultInputOption;
62
                    } else {
63
                        $this->value = '';
64
                    }
65
                    break;
66
67
                case \EWW\Dpf\Domain\Model\MetadataObject::checkbox:
68
                    if (!empty($defaultValue)) {
69
                        $this->value = 'yes';
70
                    } else {
71
                        $this->value = '';
72
                    }
73
                    break;
74
75
                default:
76
                    $this->value = $defaultValue;
77
                    break;
78
            }
79
        } else {
80
            $this->value = $value;
81
        }
82
    }
83
84
    public function getInputField()
85
    {
86
        return $this->inputField;
87
    }
88
89
    public function setInputField($inputField)
90
    {
91
        $this->inputField = $inputField;
92
    }
93
94
    /**
95
     *
96
     * @return array
97
     */
98
    public function getInputOptions()
99
    {
100
        return $this->inputOptions;
101
    }
102
103
    /**
104
     *
105
     * @param \EWW\Dpf\Domain\Model\InputOptionList $inputOptionList
106
     */
107
    public function setInputOptions(\EWW\Dpf\Domain\Model\InputOptionList $inputOptionList = null)
108
    {
109
110
        $this->inputOptions = array();
111
112
        if ($inputOptionList) {
113
            $this->inputOptions[''] = '';
114
            foreach ($inputOptionList->getInputOptions() as $option => $label) {
115
                $this->inputOptions[$option] = $label;
116
            }
117
118
            $this->defaultInputOption = trim($inputOptionList->getDefaultValue());
119
        }
120
121
    }
122
123
    /**
124
     * Returns the fillOutService
125
     *
126
     * @return string $fillOutService
127
     */
128
    public function getFillOutService()
129
    {
130
        return $this->fillOutService;
131
    }
132
133
    /**
134
     * Sets the fillOutService
135
     *
136
     * @param string $fillOutService
137
     * @return void
138
     */
139
    public function setFillOutService($fillOutService)
140
    {
141
        $this->fillOutService = $fillOutService;
142
    }
143
144
    /**
145
     * Returns the consent
146
     *
147
     * @return boolean $consent
148
     */
149
    public function getConsent()
150
    {
151
        return $this->consent;
152
    }
153
154
    /**
155
     * Sets the consent
156
     *
157
     * @param boolean $consent
158
     * @return void
159
     */
160
    public function setConsent($consent)
161
    {
162
        $this->consent = $consent;
163
    }
164
165
    public function getHasDefaultValue()
166
    {
167
        return $this->hasDefaultValue;
168
    }
169
170
    public function getValidation()
171
    {
172
        return $this->validation;
173
    }
174
175
    public function setValidation($validation)
176
    {
177
        $this->validation = $validation;
178
    }
179
180
    public function getDataType()
181
    {
182
        return $this->dataType;
183
    }
184
185
    public function setDataType($dataType)
186
    {
187
        $this->dataType = $dataType;
188
    }
189
190
    public function getGndFieldUid() {
191
        return $this->gndFieldUid;
192
    }
193
194
    public function setGndFieldUid($fieldId) {
195
        $this->gndFieldUid = $fieldId;
196
    }
197
}
198