|
|
@@ -8,7 +8,24 @@ class DocumentStorageService
|
|
|
|
|
|
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
|