@@ -154,13 +154,13 @@ discard block |
||
154 | 154 | try |
155 | 155 | { |
156 | 156 | $xFilesystem->createDirectory($sUploadDir); |
157 | - if($xFilesystem->visibility($sUploadDir) !== Visibility::PUBLIC) |
|
157 | + if ($xFilesystem->visibility($sUploadDir) !== Visibility::PUBLIC) |
|
158 | 158 | { |
159 | 159 | throw new RequestException($this->xTranslator->trans('errors.upload.access')); |
160 | 160 | } |
161 | 161 | return $sUploadDir; |
162 | 162 | } |
163 | - catch(FilesystemException $e) |
|
163 | + catch (FilesystemException $e) |
|
164 | 164 | { |
165 | 165 | jaxon()->logger()->error('Filesystem error', ['message' => $e->getMessage()]); |
166 | 166 | throw new RequestException($this->xTranslator->trans('errors.upload.access')); |
@@ -204,14 +204,14 @@ discard block |
||
204 | 204 | private function makeUploadedFile(UploadedFile $xHttpFile, string $sUploadDir, string $sField): File |
205 | 205 | { |
206 | 206 | // Check the uploaded file validity |
207 | - if($xHttpFile->getError()) |
|
207 | + if ($xHttpFile->getError()) |
|
208 | 208 | { |
209 | 209 | throw new RequestException($this->xTranslator->trans('errors.upload.failed', ['name' => $sField])); |
210 | 210 | } |
211 | 211 | |
212 | 212 | // Filename without the extension. Needs to be sanitized. |
213 | 213 | $sName = pathinfo($xHttpFile->getClientFilename(), PATHINFO_FILENAME); |
214 | - if($this->cNameSanitizer !== null) |
|
214 | + if ($this->cNameSanitizer !== null) |
|
215 | 215 | { |
216 | 216 | $sName = (string)call_user_func($this->cNameSanitizer, $sName, $sField, $this->sUploadFieldId); |
217 | 217 | } |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | // Set the user file data |
220 | 220 | $xFile = File::fromHttpFile($this->xFileStorage->filesystem($sField), $xHttpFile, $sUploadDir, $sName); |
221 | 221 | // Verify file validity (format, size) |
222 | - if(!$this->xValidator->validateUploadedFile($sField, $xFile)) |
|
222 | + if (!$this->xValidator->validateUploadedFile($sField, $xFile)) |
|
223 | 223 | { |
224 | 224 | throw new RequestException($this->xValidator->getErrorMessage()); |
225 | 225 | } |
@@ -244,16 +244,16 @@ discard block |
||
244 | 244 | |
245 | 245 | $aUserFiles = []; |
246 | 246 | $this->aAllFiles = []; // A flat list of all uploaded files |
247 | - foreach($aTempFiles as $sField => $aFiles) |
|
247 | + foreach ($aTempFiles as $sField => $aFiles) |
|
248 | 248 | { |
249 | 249 | $aUserFiles[$sField] = []; |
250 | 250 | // Get the path to the upload dir |
251 | 251 | $sUploadDir = $this->getUploadDir($sField); |
252 | - if(!is_array($aFiles)) |
|
252 | + if (!is_array($aFiles)) |
|
253 | 253 | { |
254 | 254 | $aFiles = [$aFiles]; |
255 | 255 | } |
256 | - foreach($aFiles as $xHttpFile) |
|
256 | + foreach ($aFiles as $xHttpFile) |
|
257 | 257 | { |
258 | 258 | $aUserFiles[$sField][] = $this->makeUploadedFile($xHttpFile, $sUploadDir, $sField); |
259 | 259 | } |
@@ -261,12 +261,12 @@ discard block |
||
261 | 261 | // Copy the uploaded files from the temp dir to the user dir |
262 | 262 | try |
263 | 263 | { |
264 | - foreach($this->aAllFiles as $aFiles) |
|
264 | + foreach ($this->aAllFiles as $aFiles) |
|
265 | 265 | { |
266 | 266 | $aFiles['user']->filesystem()->write($aFiles['user']->path(), $aFiles['temp']->getStream()); |
267 | 267 | } |
268 | 268 | } |
269 | - catch(FilesystemException $e) |
|
269 | + catch (FilesystemException $e) |
|
270 | 270 | { |
271 | 271 | jaxon()->logger()->error('Filesystem error', ['message' => $e->getMessage()]); |
272 | 272 | throw new RequestException($this->xTranslator->trans('errors.upload.access')); |
@@ -286,10 +286,10 @@ discard block |
||
286 | 286 | { |
287 | 287 | // Convert uploaded file to an array |
288 | 288 | $aFiles = []; |
289 | - foreach($aUserFiles as $sField => $aFieldFiles) |
|
289 | + foreach ($aUserFiles as $sField => $aFieldFiles) |
|
290 | 290 | { |
291 | 291 | $aFiles[$sField] = []; |
292 | - foreach($aFieldFiles as $aFieldFile) |
|
292 | + foreach ($aFieldFiles as $aFieldFile) |
|
293 | 293 | { |
294 | 294 | $aFiles[$sField][] = $aFieldFile->toTempData(); |
295 | 295 | } |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | { |
302 | 302 | $this->xFileStorage->filesystem()->write($sUploadDir . $sTempFile . '.json', json_encode($aFiles)); |
303 | 303 | } |
304 | - catch(FilesystemException $e) |
|
304 | + catch (FilesystemException $e) |
|
305 | 305 | { |
306 | 306 | jaxon()->logger()->error('Filesystem error', ['message' => $e->getMessage()]); |
307 | 307 | throw new RequestException($this->xTranslator->trans('errors.upload.access')); |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | private function getUploadTempFile(string $sTempFile): string |
321 | 321 | { |
322 | 322 | // Verify file name validity |
323 | - if(!$this->xValidator->validateTempFileName($sTempFile)) |
|
323 | + if (!$this->xValidator->validateTempFileName($sTempFile)) |
|
324 | 324 | { |
325 | 325 | throw new RequestException($this->xTranslator->trans('errors.upload.invalid')); |
326 | 326 | } |
@@ -328,13 +328,13 @@ discard block |
||
328 | 328 | $sUploadTempFile = $sUploadDir . $sTempFile . '.json'; |
329 | 329 | try |
330 | 330 | { |
331 | - if($this->xFileStorage->filesystem()->visibility($sUploadTempFile) !== Visibility::PUBLIC) |
|
331 | + if ($this->xFileStorage->filesystem()->visibility($sUploadTempFile) !== Visibility::PUBLIC) |
|
332 | 332 | { |
333 | 333 | throw new RequestException($this->xTranslator->trans('errors.upload.access')); |
334 | 334 | } |
335 | 335 | return $sUploadTempFile; |
336 | 336 | } |
337 | - catch(FilesystemException $e) |
|
337 | + catch (FilesystemException $e) |
|
338 | 338 | { |
339 | 339 | jaxon()->logger()->error('Filesystem error', ['message' => $e->getMessage()]); |
340 | 340 | throw new RequestException($this->xTranslator->trans('errors.upload.access')); |
@@ -358,15 +358,15 @@ discard block |
||
358 | 358 | { |
359 | 359 | $aFiles = json_decode($xFileSystem->read($sUploadTempFile), true); |
360 | 360 | } |
361 | - catch(FilesystemException $e) |
|
361 | + catch (FilesystemException $e) |
|
362 | 362 | { |
363 | 363 | throw new RequestException($this->xTranslator->trans('errors.upload.access')); |
364 | 364 | } |
365 | 365 | $aUserFiles = []; |
366 | - foreach($aFiles as $sField => $aFieldFiles) |
|
366 | + foreach ($aFiles as $sField => $aFieldFiles) |
|
367 | 367 | { |
368 | 368 | $aUserFiles[$sField] = []; |
369 | - foreach($aFieldFiles as $aFieldFile) |
|
369 | + foreach ($aFieldFiles as $aFieldFile) |
|
370 | 370 | { |
371 | 371 | $aUserFiles[$sField][] = File::fromTempFile($this->xFileStorage->filesystem($sField), $aFieldFile); |
372 | 372 | } |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | { |
376 | 376 | $xFileSystem->delete($sUploadTempFile); |
377 | 377 | } |
378 | - catch(FilesystemException $e) |
|
378 | + catch (FilesystemException $e) |
|
379 | 379 | { |
380 | 380 | jaxon()->logger()->warning('Filesystem error', ['message' => $e->getMessage()]); |
381 | 381 | } |