diff --git a/composer.json b/composer.json index 427c5e9..7cf8fde 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/composer.lock b/composer.lock index f45f0c8..1bc2382 100644 --- a/composer.lock +++ b/composer.lock @@ -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": "michel.chowanski@office-partner.de" + } + ], + "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": "michel.chowanski@bestit-online.de" + } + ], + "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", diff --git a/config/bundles.php b/config/bundles.php index 327b088..2029c8c 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -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], ]; diff --git a/config/packages/flagception.yaml b/config/packages/flagception.yaml new file mode 100644 index 0000000..a2a02d2 --- /dev/null +++ b/config/packages/flagception.yaml @@ -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 diff --git a/src/Controller/Administrative/Document/CheckController.php b/src/Controller/Administrative/Document/CheckController.php index a17eda4..3259de1 100644 --- a/src/Controller/Administrative/Document/CheckController.php +++ b/src/Controller/Administrative/Document/CheckController.php @@ -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'); + } } } diff --git a/src/Controller/Teamer/Disposition/DetailController.php b/src/Controller/Teamer/Disposition/DetailController.php index 862e99e..e8a159d 100644 --- a/src/Controller/Teamer/Disposition/DetailController.php +++ b/src/Controller/Teamer/Disposition/DetailController.php @@ -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(); diff --git a/symfony.lock b/symfony.lock index d3be278..f9d7378 100644 --- a/symfony.lock +++ b/symfony.lock @@ -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" },