9
9
10
10
namespace Zend \InputFilter ;
11
11
12
- use Zend \Validator \File \UploadFile as UploadValidator ;
13
-
14
12
/**
15
13
* FileInput is a special Input type for handling uploaded files.
16
14
*
@@ -32,29 +30,6 @@ class FileInput extends Input
32
30
*/
33
31
protected $ isValid = false ;
34
32
35
- /**
36
- * @var bool
37
- */
38
- protected $ autoPrependUploadValidator = true ;
39
-
40
- /**
41
- * @param bool $value Enable/Disable automatically prepending an Upload validator
42
- * @return FileInput
43
- */
44
- public function setAutoPrependUploadValidator ($ value )
45
- {
46
- $ this ->autoPrependUploadValidator = $ value ;
47
- return $ this ;
48
- }
49
-
50
- /**
51
- * @return bool
52
- */
53
- public function getAutoPrependUploadValidator ()
54
- {
55
- return $ this ->autoPrependUploadValidator ;
56
- }
57
-
58
33
/**
59
34
* @return mixed
60
35
*/
@@ -83,29 +58,6 @@ public function getValue()
83
58
return $ value ;
84
59
}
85
60
86
- /**
87
- * Checks if the raw input value is an empty file input eg: no file was uploaded
88
- *
89
- * @param $rawValue
90
- * @return bool
91
- */
92
- public function isEmptyFile ($ rawValue )
93
- {
94
- if (!is_array ($ rawValue )) {
95
- return true ;
96
- }
97
-
98
- if (isset ($ rawValue ['error ' ]) && $ rawValue ['error ' ] === UPLOAD_ERR_NO_FILE ) {
99
- return true ;
100
- }
101
-
102
- if (count ($ rawValue ) === 1 && isset ($ rawValue [0 ])) {
103
- return $ this ->isEmptyFile ($ rawValue [0 ]);
104
- }
105
-
106
- return false ;
107
- }
108
-
109
61
/**
110
62
* @param mixed $context Extra "context" to provide the validator
111
63
* @return bool
@@ -114,10 +66,7 @@ public function isValid($context = null)
114
66
{
115
67
$ rawValue = $ this ->getRawValue ();
116
68
$ hasValue = $ this ->hasValue ();
117
- $ empty = $ this ->isEmptyFile ($ rawValue );
118
69
$ required = $ this ->isRequired ();
119
- $ allowEmpty = $ this ->allowEmpty ();
120
- $ continueIfEmpty = $ this ->continueIfEmpty ();
121
70
122
71
if (! $ hasValue && ! $ required ) {
123
72
return true ;
@@ -130,15 +79,6 @@ public function isValid($context = null)
130
79
return false ;
131
80
}
132
81
133
- if ($ empty && ! $ required && ! $ continueIfEmpty ) {
134
- return true ;
135
- }
136
-
137
- if ($ empty && $ allowEmpty && ! $ continueIfEmpty ) {
138
- return true ;
139
- }
140
-
141
- $ this ->injectUploadValidator ();
142
82
$ validator = $ this ->getValidatorChain ();
143
83
//$value = $this->getValue(); // Do not run the filters yet for File uploads (see getValue())
144
84
@@ -168,53 +108,4 @@ public function isValid($context = null)
168
108
169
109
return $ this ->isValid ;
170
110
}
171
-
172
- /**
173
- * @return void
174
- */
175
- protected function injectUploadValidator ()
176
- {
177
- if (!$ this ->autoPrependUploadValidator ) {
178
- return ;
179
- }
180
- $ chain = $ this ->getValidatorChain ();
181
-
182
- // Check if Upload validator is already first in chain
183
- $ validators = $ chain ->getValidators ();
184
- if (isset ($ validators [0 ]['instance ' ])
185
- && $ validators [0 ]['instance ' ] instanceof UploadValidator
186
- ) {
187
- $ this ->autoPrependUploadValidator = false ;
188
- return ;
189
- }
190
-
191
- $ chain ->prependByName ('fileuploadfile ' , [], true );
192
- $ this ->autoPrependUploadValidator = false ;
193
- }
194
-
195
- /**
196
- * @deprecated 2.4.8 See note on parent class. Removal does not affect this class.
197
- *
198
- * No-op, NotEmpty validator does not apply for FileInputs.
199
- * See also: BaseInputFilter::isValid()
200
- *
201
- * @return void
202
- */
203
- protected function injectNotEmptyValidator ()
204
- {
205
- $ this ->notEmptyValidator = true ;
206
- }
207
-
208
- /**
209
- * @param InputInterface $input
210
- * @return FileInput
211
- */
212
- public function merge (InputInterface $ input )
213
- {
214
- parent ::merge ($ input );
215
- if ($ input instanceof FileInput) {
216
- $ this ->setAutoPrependUploadValidator ($ input ->getAutoPrependUploadValidator ());
217
- }
218
- return $ this ;
219
- }
220
111
}
0 commit comments