Skip to content

Commit

Permalink
Do not flush when it should be done elsewhere
Browse files Browse the repository at this point in the history
  • Loading branch information
loevgaard committed Oct 7, 2024
1 parent 149b15c commit c176483
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
12 changes: 0 additions & 12 deletions src/Modifier/OrderGiftCardAmountModifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Setono\SyliusGiftCardPlugin\Modifier;

use Doctrine\Persistence\ObjectManager;
use RuntimeException;
use Setono\SyliusGiftCardPlugin\Model\AdjustmentInterface;
use Setono\SyliusGiftCardPlugin\Model\GiftCardInterface;
Expand All @@ -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) {
Expand All @@ -41,8 +33,6 @@ public function decrement(OrderInterface $order): void
$giftCard->setAmount($giftCard->getAmount() - $amount);
}
}

$this->giftCardManager->flush();
}

public function increment(OrderInterface $order): void
Expand All @@ -56,8 +46,6 @@ public function increment(OrderInterface $order): void
$giftCard->enable();
}
}

$this->giftCardManager->flush();
}

private static function getGiftCard(OrderInterface $order, string $code): GiftCardInterface
Expand Down
4 changes: 1 addition & 3 deletions src/Resources/config/services/modifier.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
<!-- Needs to be public because it is called from the state machine -->
<service id="setono_sylius_gift_card.modifier.order_gift_card_amount"
class="Setono\SyliusGiftCardPlugin\Modifier\OrderGiftCardAmountModifier"
public="true">
<argument type="service" id="setono_sylius_gift_card.manager.gift_card"/>
</service>
public="true"/>
</services>
</container>

0 comments on commit c176483

Please sign in to comment.