fix creation file
This commit is contained in:
parent
70aed1fbe0
commit
4ce0f3c350
@ -602,6 +602,9 @@ class InvoicePdfService
|
||||
$filenames = [];
|
||||
|
||||
foreach ($factureFolders as $folder) {
|
||||
// Créer le chemin complet étape par étape
|
||||
$this->ensurePathExists($storage, $folder);
|
||||
|
||||
$ff_pdf = $folder . $pdfFilename . '.pdf';
|
||||
|
||||
try {
|
||||
@ -613,6 +616,8 @@ class InvoicePdfService
|
||||
$file_pdf->putContent($pdfContent);
|
||||
$filenames[] = $ff_pdf;
|
||||
} catch (\Throwable $e) {
|
||||
// Supprimez ce var_dump pour éviter l'erreur de headers
|
||||
// var_dump("yyyyyyyyyyyyyyyyyyyy".$e->getMessage());
|
||||
error_log("ERROR on file '$ff_pdf': " . $e->getMessage());
|
||||
continue;
|
||||
}
|
||||
@ -620,4 +625,26 @@ class InvoicePdfService
|
||||
|
||||
return $filenames;
|
||||
}
|
||||
|
||||
private function ensurePathExists($storage, $path)
|
||||
{
|
||||
$parts = explode('/', trim($path, '/'));
|
||||
$currentPath = '';
|
||||
|
||||
foreach ($parts as $part) {
|
||||
if (empty($part)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$currentPath .= '/' . $part;
|
||||
|
||||
try {
|
||||
if (!$storage->nodeExists($currentPath)) {
|
||||
$storage->newFolder($currentPath);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
error_log("Cannot create folder '$currentPath': " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user