ljoaquim 1 неделя назад
Родитель
Сommit
a41c089525
1 измененных файлов с 18 добавлено и 1 удалено
  1. 18 1
      services/DocumentStorageService.php

+ 18 - 1
services/DocumentStorageService.php

@@ -8,7 +8,24 @@ class DocumentStorageService
 
 
     public function __construct(?string $rootDir = null)
     public function __construct(?string $rootDir = null)
     {
     {
-        $this->rootDir = $rootDir ?? ($_ENV['DOCUMENTS_ROOT'] ?? '/data/documents');
+        if (is_string($rootDir) && trim($rootDir) !== '') {
+            $this->rootDir = $rootDir;
+            return;
+        }
+
+        $documentsRoot = (string)($_ENV['DOCUMENTS_ROOT'] ?? '');
+        if (trim($documentsRoot) !== '') {
+            $this->rootDir = $documentsRoot;
+            return;
+        }
+
+        $appRootDir = (string)($_ENV['ROOT_DIR'] ?? '');
+        if (trim($appRootDir) !== '') {
+            $this->rootDir = rtrim($appRootDir, '/') . '/data/documents';
+            return;
+        }
+
+        $this->rootDir = dirname(__DIR__) . '/data/documents';
     }
     }
 
 
     public function sanitizeDocumentType(string $documentType): string
     public function sanitizeDocumentType(string $documentType): string