feat: feature flags for sanitizing and stamping of uploads

This commit is contained in:
Björn Fromme
2025-03-18 18:14:25 +01:00
parent 3ad8b59ba1
commit ca8997ab19
7 changed files with 178 additions and 10 deletions
+1
View File
@@ -19,6 +19,7 @@
"doctrine/doctrine-bundle": "^2.10", "doctrine/doctrine-bundle": "^2.10",
"doctrine/doctrine-migrations-bundle": "^3.2", "doctrine/doctrine-migrations-bundle": "^3.2",
"doctrine/orm": "^2.15", "doctrine/orm": "^2.15",
"flagception/flagception-bundle": "^6.0",
"knplabs/knp-menu-bundle": "^3.2", "knplabs/knp-menu-bundle": "^3.2",
"knplabs/knp-paginator-bundle": "^6.2", "knplabs/knp-paginator-bundle": "^6.2",
"liip/imagine-bundle": "^2.11", "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", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "902495c1d53e43f8de93c4f162805e7f", "content-hash": "52ec6ca4d15ec27e3586b5bab26b528c",
"packages": [ "packages": [
{ {
"name": "beberlei/doctrineextensions", "name": "beberlei/doctrineextensions",
@@ -1597,6 +1597,139 @@
], ],
"time": "2024-12-27T00:36:43+00:00" "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", "name": "imagine/imagine",
"version": "1.5.0", "version": "1.5.0",
+1
View File
@@ -19,4 +19,5 @@ return [
Knp\Bundle\PaginatorBundle\KnpPaginatorBundle::class => ['all' => true], Knp\Bundle\PaginatorBundle\KnpPaginatorBundle::class => ['all' => true],
Nelmio\SecurityBundle\NelmioSecurityBundle::class => ['all' => true], Nelmio\SecurityBundle\NelmioSecurityBundle::class => ['all' => true],
Symfony\UX\TwigComponent\TwigComponentBundle::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\Model\DocumentCheckDto;
use App\Service\Pdf\InvoiceApprover; use App\Service\Pdf\InvoiceApprover;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Flagception\Manager\FeatureManagerInterface;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\DependencyInjection\Attribute\Target; use Symfony\Component\DependencyInjection\Attribute\Target;
@@ -32,7 +33,8 @@ class CheckController extends AbstractController
private readonly WorkflowInterface $workflow, private readonly WorkflowInterface $workflow,
private readonly EventDispatcherInterface $eventDispatcher, private readonly EventDispatcherInterface $eventDispatcher,
private readonly InvoiceApprover $invoiceApprover, 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) ->setStatus($status)
; ;
if (Upload::TYPE_INVOICE === $document->getType()) { if (true === $this->featureManager->isActive('stamp_invoices')) {
try { if (Upload::TYPE_INVOICE === $document->getType()) {
$this->invoiceApprover->render($document->getDisposition()); try {
} catch (\InvalidArgumentException $e) { $this->invoiceApprover->render($document->getDisposition());
$this->addFlash('error', 'Die Honorarnote ist nicht als PDF hochgeladen worden'); } 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\Model\UploadSessionDto;
use App\Service\Upload\UploadHandler; use App\Service\Upload\UploadHandler;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Flagception\Manager\FeatureManagerInterface;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\DependencyInjection\Attribute\Target; use Symfony\Component\DependencyInjection\Attribute\Target;
@@ -31,7 +32,8 @@ class DetailController extends AbstractController
#[Target('disposition')] #[Target('disposition')]
private readonly WorkflowInterface $workflow, private readonly WorkflowInterface $workflow,
private readonly EventDispatcherInterface $eventDispatcher, 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->moveUploadSessionFilesFromOrphanage(Upload::TYPE_CONTRACT, $uploadSession);
$this->uploadHandler->destroyUploadSession(); $this->uploadHandler->destroyUploadSession();
$this->uploadHandler->ensurePdf($upload);
if (true === $this->featureManager->isActive('sanitize_uploads')) {
$this->uploadHandler->ensurePdf($upload);
}
$this->entityManager->flush(); $this->entityManager->flush();
@@ -118,7 +123,10 @@ class DetailController extends AbstractController
$this->uploadHandler->moveUploadSessionFilesFromOrphanage(Upload::TYPE_INVOICE, $uploadSession); $this->uploadHandler->moveUploadSessionFilesFromOrphanage(Upload::TYPE_INVOICE, $uploadSession);
$this->uploadHandler->destroyUploadSession(); $this->uploadHandler->destroyUploadSession();
$this->uploadHandler->ensurePdf($upload);
if (true === $this->featureManager->isActive('sanitize_uploads')) {
$this->uploadHandler->ensurePdf($upload);
}
$this->entityManager->flush(); $this->entityManager->flush();
+12
View File
@@ -26,6 +26,18 @@
"migrations/.gitignore" "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": { "knplabs/knp-menu-bundle": {
"version": "v3.2.0" "version": "v3.2.0"
}, },