From 82f63e4d87e21fa3dbd60aa2149d537971181abb Mon Sep 17 00:00:00 2001 From: Martin Grossmann Date: Thu, 2 Nov 2023 12:38:15 +0100 Subject: [PATCH 1/3] removed unnecessary comment --- src/Model/Order/OrderRepository.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Model/Order/OrderRepository.php b/src/Model/Order/OrderRepository.php index 6d05a3e37a..254187fb9e 100644 --- a/src/Model/Order/OrderRepository.php +++ b/src/Model/Order/OrderRepository.php @@ -23,7 +23,6 @@ public function __construct(EntityManagerInterface $entityManager) /** * @return \Doctrine\ORM\QueryBuilder - * @internal This will be replaced by \Shopsys\FrameworkBundle\Model\Order::getOrderRepository() with visibility set to public */ protected function createOrderQueryBuilder() { From 12218dd7d29170b124a345ac55ccaf8640153a3c Mon Sep 17 00:00:00 2001 From: Martin Grossmann Date: Thu, 2 Nov 2023 12:58:19 +0100 Subject: [PATCH 2/3] getByUuid is now a part of framework order facade - renamed Frontend Api OrderFacade to OrderApiFacade so it's more readable --- .../{OrderFacade.php => OrderApiFacade.php} | 23 +++++++++++++++++-- src/Model/Resolver/Order/OrderQuery.php | 8 +++---- src/Model/Resolver/Order/OrdersQuery.php | 10 ++++---- 3 files changed, 30 insertions(+), 11 deletions(-) rename src/Model/Order/{OrderFacade.php => OrderApiFacade.php} (62%) diff --git a/src/Model/Order/OrderFacade.php b/src/Model/Order/OrderApiFacade.php similarity index 62% rename from src/Model/Order/OrderFacade.php rename to src/Model/Order/OrderApiFacade.php index 5ed05e8176..d41956722d 100644 --- a/src/Model/Order/OrderFacade.php +++ b/src/Model/Order/OrderApiFacade.php @@ -5,15 +5,34 @@ namespace Shopsys\FrontendApiBundle\Model\Order; use Shopsys\FrameworkBundle\Model\Customer\User\CustomerUser; +use Shopsys\FrameworkBundle\Model\Order\Exception\OrderNotFoundException; use Shopsys\FrameworkBundle\Model\Order\Order; +use Shopsys\FrameworkBundle\Model\Order\OrderFacade; +use Shopsys\FrontendApiBundle\Model\Resolver\Order\Exception\OrderNotFoundUserError; -class OrderFacade +class OrderApiFacade { /** * @param \Shopsys\FrontendApiBundle\Model\Order\OrderRepository $orderRepository + * @param \Shopsys\FrameworkBundle\Model\Order\OrderFacade $orderFacade */ - public function __construct(protected readonly OrderRepository $orderRepository) + public function __construct( + protected readonly OrderRepository $orderRepository, + protected readonly OrderFacade $orderFacade, + ) { + } + + /** + * @param string $orderUuid + * @return \Shopsys\FrameworkBundle\Model\Order\Order + */ + public function getByUuid(string $orderUuid): Order { + try { + return $this->orderFacade->getByUuid($orderUuid); + } catch (OrderNotFoundException) { + throw new OrderNotFoundUserError('Order with UUID \'' . $orderUuid . '\' not found.'); + } } /** diff --git a/src/Model/Resolver/Order/OrderQuery.php b/src/Model/Resolver/Order/OrderQuery.php index 6723d0de2a..e45157dc49 100644 --- a/src/Model/Resolver/Order/OrderQuery.php +++ b/src/Model/Resolver/Order/OrderQuery.php @@ -10,7 +10,7 @@ use Shopsys\FrameworkBundle\Model\Order\Exception\OrderNotFoundException; use Shopsys\FrameworkBundle\Model\Order\Order; use Shopsys\FrameworkBundle\Model\Order\OrderFacade; -use Shopsys\FrontendApiBundle\Model\Order\OrderFacade as FrontendApiOrderFacade; +use Shopsys\FrontendApiBundle\Model\Order\OrderApiFacade; use Shopsys\FrontendApiBundle\Model\Resolver\AbstractQuery; use Shopsys\FrontendApiBundle\Model\Resolver\Order\Exception\InvalidAccessUserError; use Shopsys\FrontendApiBundle\Model\Resolver\Order\Exception\OrderNotFoundUserError; @@ -21,13 +21,13 @@ class OrderQuery extends AbstractQuery * @param \Shopsys\FrameworkBundle\Model\Customer\User\CurrentCustomerUser $currentCustomerUser * @param \Shopsys\FrameworkBundle\Model\Order\OrderFacade $orderFacade * @param \Shopsys\FrameworkBundle\Component\Domain\Domain $domain - * @param \Shopsys\FrontendApiBundle\Model\Order\OrderFacade $frontendApiOrderFacade + * @param \Shopsys\FrontendApiBundle\Model\Order\OrderApiFacade $orderApiFacade */ public function __construct( protected readonly CurrentCustomerUser $currentCustomerUser, protected readonly OrderFacade $orderFacade, protected readonly Domain $domain, - protected readonly FrontendApiOrderFacade $frontendApiOrderFacade, + protected readonly OrderApiFacade $orderApiFacade, ) { } @@ -64,6 +64,6 @@ protected function getOrderForCustomerUserByUuid( CustomerUser $customerUser, string $uuid, ): Order { - return $this->frontendApiOrderFacade->getByUuidAndCustomerUser($uuid, $customerUser); + return $this->orderApiFacade->getByUuidAndCustomerUser($uuid, $customerUser); } } diff --git a/src/Model/Resolver/Order/OrdersQuery.php b/src/Model/Resolver/Order/OrdersQuery.php index 452c5288e4..48e0ff318b 100644 --- a/src/Model/Resolver/Order/OrdersQuery.php +++ b/src/Model/Resolver/Order/OrdersQuery.php @@ -7,7 +7,7 @@ use Overblog\GraphQLBundle\Definition\Argument; use Overblog\GraphQLBundle\Relay\Connection\Paginator; use Shopsys\FrameworkBundle\Model\Customer\User\CurrentCustomerUser; -use Shopsys\FrontendApiBundle\Model\Order\OrderFacade; +use Shopsys\FrontendApiBundle\Model\Order\OrderApiFacade; use Shopsys\FrontendApiBundle\Model\Resolver\AbstractQuery; use Shopsys\FrontendApiBundle\Model\Token\Exception\InvalidTokenUserMessageException; @@ -17,11 +17,11 @@ class OrdersQuery extends AbstractQuery /** * @param \Shopsys\FrameworkBundle\Model\Customer\User\CurrentCustomerUser $currentCustomerUser - * @param \Shopsys\FrontendApiBundle\Model\Order\OrderFacade $orderFacade + * @param \Shopsys\FrontendApiBundle\Model\Order\OrderApiFacade $orderApiFacade */ public function __construct( protected readonly CurrentCustomerUser $currentCustomerUser, - protected readonly OrderFacade $orderFacade, + protected readonly OrderApiFacade $orderApiFacade, ) { } @@ -40,10 +40,10 @@ public function ordersQuery(Argument $argument) } $paginator = new Paginator(function ($offset, $limit) use ($customerUser) { - return $this->orderFacade->getCustomerUserOrderLimitedList($customerUser, $limit, $offset); + return $this->orderApiFacade->getCustomerUserOrderLimitedList($customerUser, $limit, $offset); }); - return $paginator->auto($argument, $this->orderFacade->getCustomerUserOrderCount($customerUser)); + return $paginator->auto($argument, $this->orderApiFacade->getCustomerUserOrderCount($customerUser)); } /** From 34ead705dcea7f6ad7fdfc89c7d02bb4848d97e8 Mon Sep 17 00:00:00 2001 From: Rostislav Vitek Date: Thu, 16 Nov 2023 12:40:11 +0100 Subject: [PATCH 3/3] FE API: Order::MAX_TRANSACTION_COUNT value is now available via Settings query - so it is not necessary to define the same constant on both SF and BE --- .../MaxAllowedPaymentTransactionsQuery.php | 31 +++++++++++++++++++ .../SettingsDecorator.types.yaml | 4 +++ 2 files changed, 35 insertions(+) create mode 100644 src/Model/Resolver/Settings/MaxAllowedPaymentTransactionsQuery.php diff --git a/src/Model/Resolver/Settings/MaxAllowedPaymentTransactionsQuery.php b/src/Model/Resolver/Settings/MaxAllowedPaymentTransactionsQuery.php new file mode 100644 index 0000000000..a3c93dff96 --- /dev/null +++ b/src/Model/Resolver/Settings/MaxAllowedPaymentTransactionsQuery.php @@ -0,0 +1,31 @@ +entityNameResolver->resolve(Order::class); + + return $orderClass::MAX_TRANSACTION_COUNT; + } +} diff --git a/src/Resources/config/graphql-types/SettingsDecorator.types.yaml b/src/Resources/config/graphql-types/SettingsDecorator.types.yaml index eb9b326189..7d790acf9a 100644 --- a/src/Resources/config/graphql-types/SettingsDecorator.types.yaml +++ b/src/Resources/config/graphql-types/SettingsDecorator.types.yaml @@ -8,3 +8,7 @@ SettingsDecorator: type: "SeoSetting!" resolve: "@=query('seoSettingsQuery')" description: "Settings related to SEO" + maxAllowedPaymentTransactions: + type: Int! + resolve: "@=query('maxAllowedPaymentTransactionsQuery')" + description: "Max allowed payment transactions (how many times is user allowed to try the same payment)"