feat: dummy replacement pdf upload for environments other than prod
This commit is contained in:
1 parent
3b99757a08
commit
8988ae7620
12 files changed
+78
-16
No files matched your search
@@ -22,6 +22,8 @@ class UploadHandler
|
||||
private readonly Sanitizer $sanitizer,
|
||||
private readonly LoggerInterface $logger,
|
||||
private readonly string $projectDir,
|
||||
private readonly string $environment,
|
||||
private readonly string $uploadReplacementFile,
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -143,6 +145,27 @@ class UploadHandler
|
||||
return true === $absolute ? sprintf('%s/%s', $this->projectDir, $relativePath) : $relativePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the upload file path, substituting a replacement file in non-production environments
|
||||
* when configured. Use this for read-only access (downloads, email attachments).
|
||||
*/
|
||||
public function getResolvedUploadFilepath(Upload $upload): string
|
||||
{
|
||||
$originalPath = $this->getUploadFilepath($upload);
|
||||
|
||||
if ('' === $this->uploadReplacementFile || 'prod' === $this->environment) {
|
||||
return $originalPath;
|
||||
}
|
||||
|
||||
$replacementPath = sprintf('%s/%s', $this->projectDir, $this->uploadReplacementFile);
|
||||
|
||||
if (false === file_exists($replacementPath)) {
|
||||
return $originalPath;
|
||||
}
|
||||
|
||||
return $replacementPath;
|
||||
}
|
||||
|
||||
public function getTempUploadFilepath(UploadDto $uploadDto, string $uploadSessionId): string
|
||||
{
|
||||
$tempUploadDir = $this->getTempUploadDir($uploadSessionId);
|
||||
|
||||
Reference in new issue
Block a user