From c176483546b7db77ee47a514177a87278ceb90a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20L=C3=B8vgaard?= Date: Mon, 7 Oct 2024 13:39:29 +0200 Subject: [PATCH] Do not flush when it should be done elsewhere --- src/Modifier/OrderGiftCardAmountModifier.php | 12 ------------ src/Resources/config/services/modifier.xml | 4 +--- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/src/Modifier/OrderGiftCardAmountModifier.php b/src/Modifier/OrderGiftCardAmountModifier.php index c7a2ff53..75faca80 100644 --- a/src/Modifier/OrderGiftCardAmountModifier.php +++ b/src/Modifier/OrderGiftCardAmountModifier.php @@ -4,7 +4,6 @@ namespace Setono\SyliusGiftCardPlugin\Modifier; -use Doctrine\Persistence\ObjectManager; use RuntimeException; use Setono\SyliusGiftCardPlugin\Model\AdjustmentInterface; use Setono\SyliusGiftCardPlugin\Model\GiftCardInterface; @@ -16,13 +15,6 @@ */ final class OrderGiftCardAmountModifier implements OrderGiftCardAmountModifierInterface { - private ObjectManager $giftCardManager; - - public function __construct(ObjectManager $giftCardManager) - { - $this->giftCardManager = $giftCardManager; - } - public function decrement(OrderInterface $order): void { foreach ($order->getAdjustments(AdjustmentInterface::ORDER_GIFT_CARD_ADJUSTMENT) as $adjustment) { @@ -41,8 +33,6 @@ public function decrement(OrderInterface $order): void $giftCard->setAmount($giftCard->getAmount() - $amount); } } - - $this->giftCardManager->flush(); } public function increment(OrderInterface $order): void @@ -56,8 +46,6 @@ public function increment(OrderInterface $order): void $giftCard->enable(); } } - - $this->giftCardManager->flush(); } private static function getGiftCard(OrderInterface $order, string $code): GiftCardInterface diff --git a/src/Resources/config/services/modifier.xml b/src/Resources/config/services/modifier.xml index 5a5d3fe2..681accde 100644 --- a/src/Resources/config/services/modifier.xml +++ b/src/Resources/config/services/modifier.xml @@ -7,8 +7,6 @@ - - + public="true"/>