@@ -130,13 +130,13 @@ discard block |
||
| 130 | 130 | try |
| 131 | 131 | { |
| 132 | 132 | $xFilesystem->createDirectory($sUploadDir); |
| 133 | - if(!$xFilesystem->directoryExists($sUploadDir)) |
|
| 133 | + if (!$xFilesystem->directoryExists($sUploadDir)) |
|
| 134 | 134 | { |
| 135 | 135 | throw new RequestException($this->xTranslator->trans('errors.upload.access')); |
| 136 | 136 | } |
| 137 | 137 | return $sUploadDir; |
| 138 | 138 | } |
| 139 | - catch(FilesystemException $e) |
|
| 139 | + catch (FilesystemException $e) |
|
| 140 | 140 | { |
| 141 | 141 | $this->xLogger->error('Filesystem error.', ['message' => $e->getMessage()]); |
| 142 | 142 | throw new RequestException($this->xTranslator->trans('errors.upload.access')); |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | public function filesystem(string $sField = ''): Filesystem |
| 153 | 153 | { |
| 154 | 154 | $sField = trim($sField); |
| 155 | - if(isset($this->aFilesystems[$sField])) |
|
| 155 | + if (isset($this->aFilesystems[$sField])) |
|
| 156 | 156 | { |
| 157 | 157 | return $this->aFilesystems[$sField]; |
| 158 | 158 | } |
@@ -160,11 +160,11 @@ discard block |
||
| 160 | 160 | // Default upload dir |
| 161 | 161 | $sStorage = $this->xConfigManager->getAppOption('upload.default.storage', 'upload'); |
| 162 | 162 | $sConfigKey = "upload.files.$sField"; |
| 163 | - if($sField !== '' && $this->xConfigManager->hasAppOption($sConfigKey)) |
|
| 163 | + if ($sField !== '' && $this->xConfigManager->hasAppOption($sConfigKey)) |
|
| 164 | 164 | { |
| 165 | 165 | $sStorage = $this->xConfigManager->getAppOption("$sConfigKey.storage", $sStorage); |
| 166 | 166 | } |
| 167 | - if(!is_string($sStorage)) |
|
| 167 | + if (!is_string($sStorage)) |
|
| 168 | 168 | { |
| 169 | 169 | throw new RequestException($this->xTranslator->trans('errors.upload.adapter')); |
| 170 | 170 | } |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | { |
| 202 | 202 | // Check the uploaded file validity |
| 203 | 203 | $nErrorCode = $xHttpFile->getError(); |
| 204 | - if($nErrorCode !== UPLOAD_ERR_OK) |
|
| 204 | + if ($nErrorCode !== UPLOAD_ERR_OK) |
|
| 205 | 205 | { |
| 206 | 206 | $this->xLogger->error('File upload error.', [ |
| 207 | 207 | 'code' => $nErrorCode, |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | |
| 216 | 216 | // Filename without the extension. Needs to be sanitized. |
| 217 | 217 | $sName = pathinfo($xHttpFile->getClientFilename(), PATHINFO_FILENAME); |
| 218 | - if($this->cNameSanitizer !== null) |
|
| 218 | + if ($this->cNameSanitizer !== null) |
|
| 219 | 219 | { |
| 220 | 220 | $sName = (string)call_user_func($this->cNameSanitizer, |
| 221 | 221 | $sName, $sField, $this->sUploadFieldId); |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | // Set the user file data |
| 225 | 225 | $xFile = File::fromHttpFile($this->filesystem($sField), $xHttpFile, $sUploadDir, $sName); |
| 226 | 226 | // Verify file validity (format, size) |
| 227 | - if(!$this->xValidator->validateUploadedFile($sField, $xFile)) |
|
| 227 | + if (!$this->xValidator->validateUploadedFile($sField, $xFile)) |
|
| 228 | 228 | { |
| 229 | 229 | throw new RequestException($this->xValidator->getErrorMessage()); |
| 230 | 230 | } |
@@ -248,16 +248,16 @@ discard block |
||
| 248 | 248 | |
| 249 | 249 | $aUserFiles = []; |
| 250 | 250 | $aAllFiles = []; // A flat list of all uploaded files |
| 251 | - foreach($aTempFiles as $sField => $aFiles) |
|
| 251 | + foreach ($aTempFiles as $sField => $aFiles) |
|
| 252 | 252 | { |
| 253 | 253 | $aUserFiles[$sField] = []; |
| 254 | 254 | // Get the path to the upload dir |
| 255 | 255 | $sUploadDir = $this->getUploadDir($sField); |
| 256 | - if(!is_array($aFiles)) |
|
| 256 | + if (!is_array($aFiles)) |
|
| 257 | 257 | { |
| 258 | 258 | $aFiles = [$aFiles]; |
| 259 | 259 | } |
| 260 | - foreach($aFiles as $xHttpFile) |
|
| 260 | + foreach ($aFiles as $xHttpFile) |
|
| 261 | 261 | { |
| 262 | 262 | $aFile = $this->makeUploadedFile($xHttpFile, $sUploadDir, $sField); |
| 263 | 263 | $aUserFiles[$sField][] = $aFile['user']; |
@@ -268,14 +268,14 @@ discard block |
||
| 268 | 268 | // Copy the uploaded files from the temp dir to the user dir |
| 269 | 269 | try |
| 270 | 270 | { |
| 271 | - foreach($aAllFiles as $aFiles) |
|
| 271 | + foreach ($aAllFiles as $aFiles) |
|
| 272 | 272 | { |
| 273 | 273 | $sPath = $aFiles['user']->path(); |
| 274 | 274 | $xContent = $aFiles['temp']->getStream(); |
| 275 | 275 | $aFiles['user']->filesystem()->write($sPath, $xContent); |
| 276 | 276 | } |
| 277 | 277 | } |
| 278 | - catch(FilesystemException $e) |
|
| 278 | + catch (FilesystemException $e) |
|
| 279 | 279 | { |
| 280 | 280 | $this->xLogger->error('Filesystem error.', ['message' => $e->getMessage()]); |
| 281 | 281 | throw new RequestException($this->xTranslator->trans('errors.upload.access')); |