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
+3
View File
@@ -66,3 +66,6 @@ [email protected]
BIN_GS=/usr/bin/gs
BIN_CONVERT=/usr/bin/convert
FEATURE_SANITIZE_UPLOADS=false
FEATURE_STAMP_INVOICES=false
+1
View File
@@ -19,6 +19,7 @@
"doctrine/doctrine-bundle": "^2.10",
"doctrine/doctrine-migrations-bundle": "^3.2",
"doctrine/orm": "^2.15",
"flagception/flagception-bundle": "^6.0",
"knplabs/knp-menu-bundle": "^3.2",
"knplabs/knp-paginator-bundle": "^6.2",
"liip/imagine-bundle": "^2.11",
Generated
+134 -1
View File
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "902495c1d53e43f8de93c4f162805e7f",
"content-hash": "52ec6ca4d15ec27e3586b5bab26b528c",
"packages": [
{
"name": "beberlei/doctrineextensions",
@@ -1597,6 +1597,139 @@
],
"time": "2024-12-27T00:36:43+00:00"
},
{
"name": "flagception/flagception",
"version": "2.0.0",
"source": {
"type": "git",
"url": "https://github.com/playox/flagception-sdk.git",
"reference": "6934e73ea1ab43611a43bf85922349a83561177b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/playox/flagception-sdk/zipball/6934e73ea1ab43611a43bf85922349a83561177b",
"reference": "6934e73ea1ab43611a43bf85922349a83561177b",
"shasum": ""
},
"require": {
"php": "^7.2||^8.0",
"psr/cache": "^1.0||^2.0||^3.0",
"symfony/expression-language": ">=2.7"
},
"require-dev": {
"php-coveralls/php-coveralls": "^2.4.3",
"phpunit/phpunit": "*",
"squizlabs/php_codesniffer": "^3.5"
},
"suggest": {
"flagception/database-activator": "Fetch feature flags from database."
},
"type": "lib",
"autoload": {
"psr-4": {
"Flagception\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michel Chowanski",
"email": "[email protected]"
}
],
"description": "Feature toggle on steroids.",
"keywords": [
"feature",
"feature-flags",
"feature-toggle",
"flagception",
"flags",
"rollout",
"testing",
"toggle"
],
"support": {
"issues": "https://github.com/playox/flagception-sdk/issues",
"source": "https://github.com/playox/flagception-sdk/tree/2.0.0"
},
"time": "2025-02-26T16:11:43+00:00"
},
{
"name": "flagception/flagception-bundle",
"version": "6.0.0",
"source": {
"type": "git",
"url": "https://github.com/playox/flagception-bundle.git",
"reference": "4a38e99bb998331dbbd7321a7dbca1aaa852a5b1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/playox/flagception-bundle/zipball/4a38e99bb998331dbbd7321a7dbca1aaa852a5b1",
"reference": "4a38e99bb998331dbbd7321a7dbca1aaa852a5b1",
"shasum": ""
},
"require": {
"flagception/flagception": "^2.0",
"php": "^8.0",
"symfony/config": "^4.4 | ^5.0 | ^6.0 | ^7.0",
"symfony/dependency-injection": "^4.4 | ^5.0 | ^6.0 | ^7.0",
"symfony/http-kernel": "^4.4 | ^5.0 | ^6.0 | ^7.0",
"symfony/yaml": "^4.4 | ^5.0 | ^6.0 | ^7.0",
"twig/twig": "^1.18|^2.0|^3.0"
},
"require-dev": {
"flagception/database-activator": "^2.0",
"php-coveralls/php-coveralls": "^2.0",
"squizlabs/php_codesniffer": "^3.3.1",
"symfony/phpunit-bridge": "^5.0 | ^6.0 | ^7.0",
"symfony/twig-bridge": "^4.4 | ^5.0 | ^6.0 | ^7.0"
},
"suggest": {
"flagception/database-activator": "Fetch feature flags from a database."
},
"type": "symfony-bundle",
"extra": {
"thanks": {
"url": "https://github.com/playox/flagception-sdk",
"name": "flagception/flagception"
}
},
"autoload": {
"psr-4": {
"Flagception\\Bundle\\FlagceptionBundle\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michel Chowanski",
"email": "[email protected]"
}
],
"description": "Feature toggle bundle on steroids.",
"keywords": [
"bundle",
"feature",
"feature-flags",
"feature-toggle",
"flagception",
"flags",
"rollout",
"symfony",
"toggle"
],
"support": {
"issues": "https://github.com/playox/flagception-bundle/issues",
"source": "https://github.com/playox/flagception-bundle/tree/6.0.0"
},
"time": "2025-02-27T13:45:44+00:00"
},
{
"name": "imagine/imagine",
"version": "1.5.0",
+1
View File
@@ -19,4 +19,5 @@ return [
Knp\Bundle\PaginatorBundle\KnpPaginatorBundle::class => ['all' => true],
Nelmio\SecurityBundle\NelmioSecurityBundle::class => ['all' => true],
Symfony\UX\TwigComponent\TwigComponentBundle::class => ['all' => true],
Flagception\Bundle\FlagceptionBundle\FlagceptionBundle::class => ['all' => true],
];
+9
View File
@@ -0,0 +1,9 @@
# See full configuration at https://github.com/bestit/flagception-bundle
flagception:
features:
sanitize_uploads:
default: false
env: FEATURE_SANITIZE_UPLOADS
stamp_invoices:
default: false
env: FEATURE_STAMP_INVOICES
@@ -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) {
}
+12
View File
@@ -26,6 +26,18 @@
"migrations/.gitignore"
]
},
"flagception/flagception-bundle": {
"version": "6.0",
"recipe": {
"repo": "github.com/symfony/recipes-contrib",
"branch": "main",
"version": "3.0",
"ref": "9f045b9e854039c20e9ecf54aa8d9868c1b841cd"
},
"files": [
"config/packages/flagception.yaml"
]
},
"knplabs/knp-menu-bundle": {
"version": "v3.2.0"
},
+3 -2
View File
@@ -66,11 +66,12 @@ class InvoiceRendererTest extends WebTestCase
->setCode('ABC123')
->setDateFrom(new \DateTimeImmutable('2023-12-01'))
->setDateTo(new \DateTimeImmutable('2023-12-08'))
->setCostUnit('FOO123')
->setCostUnit('200')
;
$jobProfile = new JobProfile();
$jobProfile->setName('Allrounder');
$jobProfile->setCostUnit('300');
$contact = new User();
$contact
@@ -84,7 +85,6 @@ class InvoiceRendererTest extends WebTestCase
->setDestination($destination)
->setJobProfile($jobProfile)
->setContact($contact)
->setCostCenter('BAR456')
;
$application = new Application($assignment, $teamer);
@@ -98,6 +98,7 @@ class InvoiceRendererTest extends WebTestCase
$invoice = new Upload();
$invoice
->setType(Upload::TYPE_INVOICE)
->setMimeType('application/pdf')
->setFilename('Honorarnote.pdf')
->setApprovedBy('FOO')
->setApprovedAt(new \DateTimeImmutable())