feat: convert uploaded contracts and invoices to pdf
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Service\Upload;
|
||||
use App\Entity\Upload;
|
||||
use App\Model\UploadDto;
|
||||
use App\Model\UploadSessionDto;
|
||||
use App\Service\Pdf\Sanitizer;
|
||||
use Oneup\UploaderBundle\Uploader\Orphanage\OrphanageManager;
|
||||
use Symfony\Component\Filesystem\Exception\IOException;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
@@ -17,6 +18,7 @@ class UploadHandler
|
||||
public function __construct(
|
||||
private readonly RequestStack $requestStack,
|
||||
private readonly OrphanageManager $orphanageManager,
|
||||
private readonly Sanitizer $sanitizer,
|
||||
private readonly string $projectDir
|
||||
) {
|
||||
}
|
||||
@@ -131,4 +133,17 @@ class UploadHandler
|
||||
{
|
||||
return sprintf('%s/uploads/temp/%s', $this->projectDir, $uploadSessionId);
|
||||
}
|
||||
|
||||
public function ensurePdf(Upload $upload): void
|
||||
{
|
||||
try {
|
||||
$filepath = $this->getUploadFilepath($upload);
|
||||
$sanitizedFilepath = $this->sanitizer->sanitizeFile($filepath);
|
||||
|
||||
if ($filepath !== $sanitizedFilepath) {
|
||||
$upload->setFilename(basename($sanitizedFilepath));
|
||||
}
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user