Skip to content
Snippets Groups Projects
Commit 4bc4192f authored by Quentin Ribac's avatar Quentin Ribac
Browse files

FEAT #17671 TIME 0:15 change error message; remove double foreach

parent 41947892
No related branches found
No related tags found
No related merge requests found
...@@ -316,7 +316,7 @@ class DocumentController ...@@ -316,7 +316,7 @@ class DocumentController
'data' => [$args['id']] 'data' => [$args['id']]
]); ]);
if (empty($filePaths)) { if (empty($filePaths)) {
return $response->withStatus(500)->withJson(['errors' => 'No documents found on Docserver']); return $response->withStatus(500)->withJson(['errors' => 'Document does not exist']);
} }
$attachments = AttachmentModel::get([ $attachments = AttachmentModel::get([
...@@ -333,20 +333,16 @@ class DocumentController ...@@ -333,20 +333,16 @@ class DocumentController
$filePaths = array_merge($filePaths, $attachmentFilePaths); $filePaths = array_merge($filePaths, $attachmentFilePaths);
} }
foreach ($docServers as $docserver) { $docServers = array_column($docServers, 'path', 'type');
foreach ($filePaths as $filePath) { foreach ($filePaths as $filePath) {
$docFilePath = $docServers[$filePath['type']] . $filePath['path'];
if ($docserver['type'] == $filePath['type']) { if (file_exists("$docFilePath")) {
$docFilePath = "{$docserver['path']}{$filePath['path']}"; AdrModel::deleteDocumentAdr([
'where' => ['id = ?'],
if (file_exists("$docFilePath")) { 'data' => [$filePath['id']]
AdrModel::deleteDocumentAdr([ ]);
'where' => ['id = ?'], unlink($docFilePath);
'data' => [$filePath['id']]
]);
unlink($docFilePath);
}
}
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment