@@ -138,39 +138,7 @@ protected function mapRequest(ServerRequestInterface $psrRequest)
138
138
/** @var \React\Http\Io\UploadedFile $file */
139
139
$ uploadedFiles = $ psrRequest ->getUploadedFiles ();
140
140
141
- $ mapFiles = function (&$ files ) use (&$ mapFiles ) {
142
- foreach ($ files as &$ file ) {
143
- if (is_array ($ file )) {
144
- $ mapFiles ($ file );
145
- } elseif ($ file instanceof UploadedFileInterface) {
146
- $ tmpname = tempnam (sys_get_temp_dir (), 'upload ' );
147
- $ this ->tempFiles [] = $ tmpname ;
148
-
149
- if (UPLOAD_ERR_NO_FILE == $ file ->getError ()) {
150
- $ file = [
151
- 'error ' => $ file ->getError (),
152
- 'name ' => $ file ->getClientFilename (),
153
- 'size ' => $ file ->getSize (),
154
- 'tmp_name ' => $ tmpname ,
155
- 'type ' => $ file ->getClientMediaType ()
156
- ];
157
- } else {
158
- if (UPLOAD_ERR_OK == $ file ->getError ()) {
159
- file_put_contents ($ tmpname , (string )$ file ->getStream ());
160
- }
161
- $ file = new SymfonyFile (
162
- $ tmpname ,
163
- $ file ->getClientFilename (),
164
- $ file ->getClientMediaType (),
165
- $ file ->getSize (),
166
- $ file ->getError (),
167
- true
168
- );
169
- }
170
- }
171
- }
172
- };
173
- $ mapFiles ($ uploadedFiles );
141
+ $ this ->mapFiles ($ uploadedFiles );
174
142
175
143
// @todo check howto handle additional headers
176
144
// @todo check howto support other HTTP methods with bodies
@@ -194,6 +162,40 @@ protected function mapRequest(ServerRequestInterface $psrRequest)
194
162
return $ syRequest ;
195
163
}
196
164
165
+ private function mapFiles (&$ files )
166
+ {
167
+ foreach ($ files as &$ file ) {
168
+ if (is_array ($ file )) {
169
+ $ this ->mapFiles ($ file );
170
+ } elseif ($ file instanceof UploadedFileInterface) {
171
+ $ tmpname = tempnam (sys_get_temp_dir (), 'upload ' );
172
+ $ this ->tempFiles [] = $ tmpname ;
173
+
174
+ if (UPLOAD_ERR_NO_FILE == $ file ->getError ()) {
175
+ $ file = [
176
+ 'error ' => $ file ->getError (),
177
+ 'name ' => $ file ->getClientFilename (),
178
+ 'size ' => $ file ->getSize (),
179
+ 'tmp_name ' => $ tmpname ,
180
+ 'type ' => $ file ->getClientMediaType (),
181
+ ];
182
+ } else {
183
+ if (UPLOAD_ERR_OK == $ file ->getError ()) {
184
+ file_put_contents ($ tmpname , (string )$ file ->getStream ());
185
+ }
186
+ $ file = new SymfonyFile (
187
+ $ tmpname ,
188
+ $ file ->getClientFilename (),
189
+ $ file ->getClientMediaType (),
190
+ $ file ->getSize (),
191
+ $ file ->getError (),
192
+ true
193
+ );
194
+ }
195
+ }
196
+ }
197
+ }
198
+
197
199
/**
198
200
* Convert Symfony\Component\HttpFoundation\Response to React\Http\Response
199
201
*
0 commit comments