From 1032297a2f346fd28d9794105d4d3a6abec912c5 Mon Sep 17 00:00:00 2001 From: hkreuter Date: Fri, 13 Dec 2024 12:59:48 +0100 Subject: [PATCH] Run with shop 8.0.x, WIP --- composer.json | 2 +- src/Voucher/Infrastructure/Voucher.php | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index 845df8ea..90d29d33 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ "require": { "php": "^8.2", "doctrine/dbal": "^v2.7", - "oxid-esales/graphql-base": "dev-b-7.2.x" + "oxid-esales/graphql-base": "dev-b-8.0.x-compatibility-OXDEV-7248" }, "conflict": { "oxid-esales/oxideshop-ce": "<7.2", diff --git a/src/Voucher/Infrastructure/Voucher.php b/src/Voucher/Infrastructure/Voucher.php index 3ec419ce..6fd119c4 100644 --- a/src/Voucher/Infrastructure/Voucher.php +++ b/src/Voucher/Infrastructure/Voucher.php @@ -12,7 +12,7 @@ use Exception; use OxidEsales\Eshop\Application\Model\Basket as EshopBasketModel; use OxidEsales\Eshop\Core\Exception\ObjectException as EshopObjectException; -use OxidEsales\EshopCommunity\Internal\Framework\Database\TransactionServiceInterface as EshopTransactionService; +use OxidEsales\EshopCommunity\Internal\Framework\Database\ConnectionFactoryInterface as EshopConnectionFactory; use OxidEsales\GraphQL\Storefront\Basket\DataType\Basket as BasketDataType; use OxidEsales\GraphQL\Storefront\Shared\Infrastructure\Basket as SharedBasketInfrastructure; use OxidEsales\GraphQL\Storefront\Shared\Shop\Voucher as StorefrontVoucherModel; @@ -29,24 +29,25 @@ final class Voucher /** @var SharedBasketInfrastructure */ private $sharedBasketInfrastructure; - /** @var EshopTransactionService */ - private $transactionService; + /** @var EshopConnectionFactory */ + private $connectionService; public function __construct( Repository $repository, SharedBasketInfrastructure $sharedBasketInfrastructure, - EshopTransactionService $transactionService + EshopConnectionFactory $connectionService ) { $this->repository = $repository; $this->sharedBasketInfrastructure = $sharedBasketInfrastructure; - $this->transactionService = $transactionService; + $this->connectionService = $connectionService; } public function addVoucher( VoucherDataType $voucher, BasketDataType $basket ): void { - $this->transactionService->begin(); + $connection = $this->connectionService->create(); + $connection->beginTransaction(); try { $basketModel = $this->sharedBasketInfrastructure->getCalculatedBasket($basket); @@ -68,11 +69,11 @@ public function addVoucher( $this->repository->addBasketIdToVoucher($basket->id(), $voucherModel->getId()); } catch (Exception $exception) { - $this->transactionService->rollback(); + $connection->rollBack(); throw VoucherNotUsable::withMessage($exception->getMessage()); } - $this->transactionService->commit(); + $connection->commit(); } public function removeVoucher(