@@ -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,20 +204,20 @@ discard block |
||
204 | 204 | private function makeUploadedFile(string $sUploadDir, string $sField, UploadedFile $xHttpFile): 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 | // Set the user file data |
212 | 212 | $xFile = File::fromHttpFile($this->xFileStorage->filesystem($sField), $sUploadDir, $xHttpFile); |
213 | 213 | // Verify file validity (format, size) |
214 | - if(!$this->xValidator->validateUploadedFile($sField, $xFile)) |
|
214 | + if (!$this->xValidator->validateUploadedFile($sField, $xFile)) |
|
215 | 215 | { |
216 | 216 | throw new RequestException($this->xValidator->getErrorMessage()); |
217 | 217 | } |
218 | 218 | // Filename without the extension. Needs to be sanitized. |
219 | 219 | $sName = pathinfo($xHttpFile->getClientFilename(), PATHINFO_FILENAME); |
220 | - if($this->cNameSanitizer !== null) |
|
220 | + if ($this->cNameSanitizer !== null) |
|
221 | 221 | { |
222 | 222 | $sName = (string)call_user_func($this->cNameSanitizer, $sName, $sField, $this->sUploadFieldId); |
223 | 223 | } |
@@ -242,16 +242,16 @@ discard block |
||
242 | 242 | |
243 | 243 | $aUserFiles = []; |
244 | 244 | $this->aAllFiles = []; // A flat list of all uploaded files |
245 | - foreach($aTempFiles as $sField => $aFiles) |
|
245 | + foreach ($aTempFiles as $sField => $aFiles) |
|
246 | 246 | { |
247 | 247 | $aUserFiles[$sField] = []; |
248 | 248 | // Get the path to the upload dir |
249 | 249 | $sUploadDir = $this->getUploadDir($sField); |
250 | - if(!is_array($aFiles)) |
|
250 | + if (!is_array($aFiles)) |
|
251 | 251 | { |
252 | 252 | $aFiles = [$aFiles]; |
253 | 253 | } |
254 | - foreach($aFiles as $xHttpFile) |
|
254 | + foreach ($aFiles as $xHttpFile) |
|
255 | 255 | { |
256 | 256 | $aUserFiles[$sField][] = $this->makeUploadedFile($sUploadDir, $sField, $xHttpFile); |
257 | 257 | } |
@@ -259,12 +259,12 @@ discard block |
||
259 | 259 | // Copy the uploaded files from the temp dir to the user dir |
260 | 260 | try |
261 | 261 | { |
262 | - foreach($this->aAllFiles as $aFiles) |
|
262 | + foreach ($this->aAllFiles as $aFiles) |
|
263 | 263 | { |
264 | 264 | $aFiles['user']->filesystem()->write($aFiles['user']->path(), $aFiles['temp']->getStream()); |
265 | 265 | } |
266 | 266 | } |
267 | - catch(FilesystemException $e) |
|
267 | + catch (FilesystemException $e) |
|
268 | 268 | { |
269 | 269 | jaxon()->logger()->error('Filesystem error', ['message' => $e->getMessage()]); |
270 | 270 | throw new RequestException($this->xTranslator->trans('errors.upload.access')); |
@@ -284,10 +284,10 @@ discard block |
||
284 | 284 | { |
285 | 285 | // Convert uploaded file to an array |
286 | 286 | $aFiles = []; |
287 | - foreach($aUserFiles as $sField => $aFieldFiles) |
|
287 | + foreach ($aUserFiles as $sField => $aFieldFiles) |
|
288 | 288 | { |
289 | 289 | $aFiles[$sField] = []; |
290 | - foreach($aFieldFiles as $aFieldFile) |
|
290 | + foreach ($aFieldFiles as $aFieldFile) |
|
291 | 291 | { |
292 | 292 | $aFiles[$sField][] = $aFieldFile->toTempData(); |
293 | 293 | } |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | { |
300 | 300 | $this->xFileStorage->filesystem()->write($sUploadDir . $sTempFile . '.json', json_encode($aFiles)); |
301 | 301 | } |
302 | - catch(FilesystemException $e) |
|
302 | + catch (FilesystemException $e) |
|
303 | 303 | { |
304 | 304 | jaxon()->logger()->error('Filesystem error', ['message' => $e->getMessage()]); |
305 | 305 | throw new RequestException($this->xTranslator->trans('errors.upload.access')); |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | private function getUploadTempFile(string $sTempFile): string |
319 | 319 | { |
320 | 320 | // Verify file name validity |
321 | - if(!$this->xValidator->validateTempFileName($sTempFile)) |
|
321 | + if (!$this->xValidator->validateTempFileName($sTempFile)) |
|
322 | 322 | { |
323 | 323 | throw new RequestException($this->xTranslator->trans('errors.upload.invalid')); |
324 | 324 | } |
@@ -326,13 +326,13 @@ discard block |
||
326 | 326 | $sUploadTempFile = $sUploadDir . $sTempFile . '.json'; |
327 | 327 | try |
328 | 328 | { |
329 | - if($this->xFileStorage->filesystem()->visibility($sUploadTempFile) !== Visibility::PUBLIC) |
|
329 | + if ($this->xFileStorage->filesystem()->visibility($sUploadTempFile) !== Visibility::PUBLIC) |
|
330 | 330 | { |
331 | 331 | throw new RequestException($this->xTranslator->trans('errors.upload.access')); |
332 | 332 | } |
333 | 333 | return $sUploadTempFile; |
334 | 334 | } |
335 | - catch(FilesystemException $e) |
|
335 | + catch (FilesystemException $e) |
|
336 | 336 | { |
337 | 337 | jaxon()->logger()->error('Filesystem error', ['message' => $e->getMessage()]); |
338 | 338 | throw new RequestException($this->xTranslator->trans('errors.upload.access')); |
@@ -356,15 +356,15 @@ discard block |
||
356 | 356 | { |
357 | 357 | $aFiles = json_decode($xFileSystem->read($sUploadTempFile), true); |
358 | 358 | } |
359 | - catch(FilesystemException $e) |
|
359 | + catch (FilesystemException $e) |
|
360 | 360 | { |
361 | 361 | throw new RequestException($this->xTranslator->trans('errors.upload.access')); |
362 | 362 | } |
363 | 363 | $aUserFiles = []; |
364 | - foreach($aFiles as $sField => $aFieldFiles) |
|
364 | + foreach ($aFiles as $sField => $aFieldFiles) |
|
365 | 365 | { |
366 | 366 | $aUserFiles[$sField] = []; |
367 | - foreach($aFieldFiles as $aFieldFile) |
|
367 | + foreach ($aFieldFiles as $aFieldFile) |
|
368 | 368 | { |
369 | 369 | $aUserFiles[$sField][] = File::fromTempFile($this->xFileStorage->filesystem($sField), $aFieldFile); |
370 | 370 | } |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | { |
374 | 374 | $xFileSystem->delete($sUploadTempFile); |
375 | 375 | } |
376 | - catch(FilesystemException $e) |
|
376 | + catch (FilesystemException $e) |
|
377 | 377 | { |
378 | 378 | jaxon()->logger()->warning('Filesystem error', ['message' => $e->getMessage()]); |
379 | 379 | } |
@@ -159,8 +159,7 @@ discard block |
||
159 | 159 | throw new RequestException($this->xTranslator->trans('errors.upload.access')); |
160 | 160 | } |
161 | 161 | return $sUploadDir; |
162 | - } |
|
163 | - catch(FilesystemException $e) |
|
162 | + } catch(FilesystemException $e) |
|
164 | 163 | { |
165 | 164 | jaxon()->logger()->error('Filesystem error', ['message' => $e->getMessage()]); |
166 | 165 | throw new RequestException($this->xTranslator->trans('errors.upload.access')); |
@@ -263,8 +262,7 @@ discard block |
||
263 | 262 | { |
264 | 263 | $aFiles['user']->filesystem()->write($aFiles['user']->path(), $aFiles['temp']->getStream()); |
265 | 264 | } |
266 | - } |
|
267 | - catch(FilesystemException $e) |
|
265 | + } catch(FilesystemException $e) |
|
268 | 266 | { |
269 | 267 | jaxon()->logger()->error('Filesystem error', ['message' => $e->getMessage()]); |
270 | 268 | throw new RequestException($this->xTranslator->trans('errors.upload.access')); |
@@ -298,8 +296,7 @@ discard block |
||
298 | 296 | try |
299 | 297 | { |
300 | 298 | $this->xFileStorage->filesystem()->write($sUploadDir . $sTempFile . '.json', json_encode($aFiles)); |
301 | - } |
|
302 | - catch(FilesystemException $e) |
|
299 | + } catch(FilesystemException $e) |
|
303 | 300 | { |
304 | 301 | jaxon()->logger()->error('Filesystem error', ['message' => $e->getMessage()]); |
305 | 302 | throw new RequestException($this->xTranslator->trans('errors.upload.access')); |
@@ -331,8 +328,7 @@ discard block |
||
331 | 328 | throw new RequestException($this->xTranslator->trans('errors.upload.access')); |
332 | 329 | } |
333 | 330 | return $sUploadTempFile; |
334 | - } |
|
335 | - catch(FilesystemException $e) |
|
331 | + } catch(FilesystemException $e) |
|
336 | 332 | { |
337 | 333 | jaxon()->logger()->error('Filesystem error', ['message' => $e->getMessage()]); |
338 | 334 | throw new RequestException($this->xTranslator->trans('errors.upload.access')); |
@@ -355,8 +351,7 @@ discard block |
||
355 | 351 | try |
356 | 352 | { |
357 | 353 | $aFiles = json_decode($xFileSystem->read($sUploadTempFile), true); |
358 | - } |
|
359 | - catch(FilesystemException $e) |
|
354 | + } catch(FilesystemException $e) |
|
360 | 355 | { |
361 | 356 | throw new RequestException($this->xTranslator->trans('errors.upload.access')); |
362 | 357 | } |
@@ -372,8 +367,7 @@ discard block |
||
372 | 367 | try |
373 | 368 | { |
374 | 369 | $xFileSystem->delete($sUploadTempFile); |
375 | - } |
|
376 | - catch(FilesystemException $e) |
|
370 | + } catch(FilesystemException $e) |
|
377 | 371 | { |
378 | 372 | jaxon()->logger()->warning('Filesystem error', ['message' => $e->getMessage()]); |
379 | 373 | } |