Merge branch 'master' into feature/timeline

This commit is contained in:
Björn Fromme
2025-03-18 20:32:53 +01:00
11 changed files with 192 additions and 14 deletions
@@ -12,6 +12,7 @@ use App\Htmx\HxRedirectResponse;
use App\Model\DocumentCheckDto;
use App\Service\Pdf\InvoiceApprover;
use Doctrine\ORM\EntityManagerInterface;
use Flagception\Manager\FeatureManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\DependencyInjection\Attribute\Target;
@@ -32,7 +33,8 @@ class CheckController extends AbstractController
private readonly WorkflowInterface $workflow,
private readonly EventDispatcherInterface $eventDispatcher,
private readonly InvoiceApprover $invoiceApprover,
private readonly LoggerInterface $logger
private readonly LoggerInterface $logger,
private readonly FeatureManagerInterface $featureManager,
) {
}
@@ -125,11 +127,13 @@ class CheckController extends AbstractController
->setStatus($status)
;
if (Upload::TYPE_INVOICE === $document->getType()) {
try {
$this->invoiceApprover->render($document->getDisposition());
} catch (\InvalidArgumentException $e) {
$this->addFlash('error', 'Die Honorarnote ist nicht als PDF hochgeladen worden');
if (true === $this->featureManager->isActive('stamp_invoices')) {
if (Upload::TYPE_INVOICE === $document->getType()) {
try {
$this->invoiceApprover->render($document->getDisposition());
} catch (\InvalidArgumentException $e) {
$this->addFlash('error', 'Die Honorarnote ist nicht als PDF hochgeladen worden');
}
}
}
@@ -11,6 +11,7 @@ use App\Form\TeamerDispositionType;
use App\Model\UploadSessionDto;
use App\Service\Upload\UploadHandler;
use Doctrine\ORM\EntityManagerInterface;
use Flagception\Manager\FeatureManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\DependencyInjection\Attribute\Target;
@@ -31,7 +32,8 @@ class DetailController extends AbstractController
#[Target('disposition')]
private readonly WorkflowInterface $workflow,
private readonly EventDispatcherInterface $eventDispatcher,
private readonly LoggerInterface $logger
private readonly LoggerInterface $logger,
private readonly FeatureManagerInterface $featureManager,
) {
}
@@ -88,7 +90,10 @@ class DetailController extends AbstractController
$this->uploadHandler->moveUploadSessionFilesFromOrphanage(Upload::TYPE_CONTRACT, $uploadSession);
$this->uploadHandler->destroyUploadSession();
$this->uploadHandler->ensurePdf($upload);
if (true === $this->featureManager->isActive('sanitize_uploads')) {
$this->uploadHandler->ensurePdf($upload);
}
$this->entityManager->flush();
@@ -118,7 +123,10 @@ class DetailController extends AbstractController
$this->uploadHandler->moveUploadSessionFilesFromOrphanage(Upload::TYPE_INVOICE, $uploadSession);
$this->uploadHandler->destroyUploadSession();
$this->uploadHandler->ensurePdf($upload);
if (true === $this->featureManager->isActive('sanitize_uploads')) {
$this->uploadHandler->ensurePdf($upload);
}
$this->entityManager->flush();
+4 -1
View File
@@ -22,7 +22,9 @@ class Sanitizer
$filesystem = new Filesystem();
if (true === $backup) {
$filesystem->copy($inputFilepath, $inputFilepath.'.bak');
$parts = pathinfo($inputFilepath);
$backupFilename = sprintf('%s/%s.orig.%s', $parts['dirname'], $parts['filename'], $parts['extension']);
$filesystem->copy($inputFilepath, $backupFilename);
}
$tempFilename = sha1($inputFilepath);
@@ -57,6 +59,7 @@ class Sanitizer
'-dNOPAUSE',
'-dQUIET',
'-dBATCH',
'-dPreserveAnnots=false',
'-sDEVICE=pdfwrite',
'-dCompatibilityLevel=1.4',
'-sOutputFile='.$outputFilepath,
+4 -1
View File
@@ -141,7 +141,10 @@ class UploadHandler
$sanitizedFilepath = $this->sanitizer->sanitizeFile($filepath);
if ($filepath !== $sanitizedFilepath) {
$upload->setFilename(basename($sanitizedFilepath));
$upload
->setFilename(basename($sanitizedFilepath))
->setMimeType('application/pdf')
;
}
} catch (\InvalidArgumentException $e) {
}