From ad25c62d1a64de775ba59edcfecfc4a56ea74528 Mon Sep 17 00:00:00 2001 From: Yaroslav Rogoza Date: Tue, 17 Jul 2018 16:34:22 +0200 Subject: [PATCH 01/13] Empty cart creation mutation added --- .../Model/Resolver/Cart/CreateEmptyCart.php | 81 +++++++++++++++++++ app/code/Magento/QuoteGraphQl/composer.json | 25 ++++++ app/code/Magento/QuoteGraphQl/etc/module.xml | 14 ++++ .../Magento/QuoteGraphQl/etc/schema.graphqls | 6 ++ .../Magento/QuoteGraphQl/registration.php | 10 +++ 5 files changed, 136 insertions(+) create mode 100644 app/code/Magento/QuoteGraphQl/Model/Resolver/Cart/CreateEmptyCart.php create mode 100644 app/code/Magento/QuoteGraphQl/composer.json create mode 100644 app/code/Magento/QuoteGraphQl/etc/module.xml create mode 100644 app/code/Magento/QuoteGraphQl/etc/schema.graphqls create mode 100644 app/code/Magento/QuoteGraphQl/registration.php diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart/CreateEmptyCart.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart/CreateEmptyCart.php new file mode 100644 index 000000000000..9d1362c5a894 --- /dev/null +++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart/CreateEmptyCart.php @@ -0,0 +1,81 @@ +cartManagement = $cartManagement; + $this->guestCartManagement = $guestCartManagement; + $this->valueFactory = $valueFactory; + $this->userContext = $userContext; + } + + /** + * {@inheritDoc} + */ + public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null) : Value + { + $customerId = $this->userContext->getUserId(); + + if ($customerId) { + $cartId = $this->cartManagement->createEmptyCartForCustomer($customerId); + } else { + $cartId = $this->guestCartManagement->createEmptyCart(); + } + + $result = function () use ($cartId) { + return $cartId; + }; + + return $this->valueFactory->create($result); + } +} \ No newline at end of file diff --git a/app/code/Magento/QuoteGraphQl/composer.json b/app/code/Magento/QuoteGraphQl/composer.json new file mode 100644 index 000000000000..d6aaba94ee31 --- /dev/null +++ b/app/code/Magento/QuoteGraphQl/composer.json @@ -0,0 +1,25 @@ +{ + "name": "magento/module-quote-graph-ql", + "description": "N/A", + "type": "magento2-module", + "require": { + "php": "~7.1.3||~7.2.0", + "magento/framework": "*" + }, + "suggest": { + "magento/module-graph-ql": "*", + "magento/module-catalog-graph-ql": "*" + }, + "license": [ + "OSL-3.0", + "AFL-3.0" + ], + "autoload": { + "files": [ + "registration.php" + ], + "psr-4": { + "Magento\\QuoteGraphQl\\": "" + } + } +} diff --git a/app/code/Magento/QuoteGraphQl/etc/module.xml b/app/code/Magento/QuoteGraphQl/etc/module.xml new file mode 100644 index 000000000000..9a0b727b1037 --- /dev/null +++ b/app/code/Magento/QuoteGraphQl/etc/module.xml @@ -0,0 +1,14 @@ + + + + + + + + + diff --git a/app/code/Magento/QuoteGraphQl/etc/schema.graphqls b/app/code/Magento/QuoteGraphQl/etc/schema.graphqls new file mode 100644 index 000000000000..46d1b97d0aea --- /dev/null +++ b/app/code/Magento/QuoteGraphQl/etc/schema.graphqls @@ -0,0 +1,6 @@ +# Copyright © Magento, Inc. All rights reserved. +# See COPYING.txt for license details. + +type Mutation { + createEmptyCart: String @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\Cart\\CreateEmptyCart") @doc(description:"Creates empty shopping cart for guest or logged in user") +} diff --git a/app/code/Magento/QuoteGraphQl/registration.php b/app/code/Magento/QuoteGraphQl/registration.php new file mode 100644 index 000000000000..8c945d902ba3 --- /dev/null +++ b/app/code/Magento/QuoteGraphQl/registration.php @@ -0,0 +1,10 @@ + Date: Tue, 17 Jul 2018 16:40:40 +0200 Subject: [PATCH 02/13] An empty line added --- .../QuoteGraphQl/Model/Resolver/Cart/CreateEmptyCart.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart/CreateEmptyCart.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart/CreateEmptyCart.php index 9d1362c5a894..1c24465e8937 100644 --- a/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart/CreateEmptyCart.php +++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart/CreateEmptyCart.php @@ -78,4 +78,4 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value return $this->valueFactory->create($result); } -} \ No newline at end of file +} From 0ef53fdc24483cfbfab112af23b57ccb3b127bc0 Mon Sep 17 00:00:00 2001 From: Yaroslav Rogoza Date: Thu, 26 Jul 2018 10:31:20 +0200 Subject: [PATCH 03/13] Quote GraphQL module is added to the root composer.json --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index f8182c96f78a..97ff95174320 100644 --- a/composer.json +++ b/composer.json @@ -183,6 +183,7 @@ "magento/module-product-video": "*", "magento/module-quote": "*", "magento/module-quote-analytics": "*", + "magento/module-quote-graph-ql": "*", "magento/module-release-notification": "*", "magento/module-reports": "*", "magento/module-require-js": "*", From a62af8e063a7afff76275982ae6b2f2bb0dff4b3 Mon Sep 17 00:00:00 2001 From: Yaroslav Rogoza Date: Tue, 31 Jul 2018 14:11:47 +0200 Subject: [PATCH 04/13] Readme and composer config adjustments --- app/code/Magento/QuoteGraphQl/README.md | 4 + app/code/Magento/QuoteGraphQl/composer.json | 3 +- composer.lock | 106 ++++++++++---------- 3 files changed, 59 insertions(+), 54 deletions(-) create mode 100644 app/code/Magento/QuoteGraphQl/README.md diff --git a/app/code/Magento/QuoteGraphQl/README.md b/app/code/Magento/QuoteGraphQl/README.md new file mode 100644 index 000000000000..05d6746b873e --- /dev/null +++ b/app/code/Magento/QuoteGraphQl/README.md @@ -0,0 +1,4 @@ +# QuoteGraphQl + +**QuoteGraphQl** provides type and resolver information for the GraphQl module +to generate quote (cart) information endpoints. Also provides endpoints for modifying a quote. diff --git a/app/code/Magento/QuoteGraphQl/composer.json b/app/code/Magento/QuoteGraphQl/composer.json index d6aaba94ee31..cc31a8b83489 100644 --- a/app/code/Magento/QuoteGraphQl/composer.json +++ b/app/code/Magento/QuoteGraphQl/composer.json @@ -4,7 +4,8 @@ "type": "magento2-module", "require": { "php": "~7.1.3||~7.2.0", - "magento/framework": "*" + "magento/framework": "*", + "magento/module-authorization": "*" }, "suggest": { "magento/module-graph-ql": "*", diff --git a/composer.lock b/composer.lock index 0966aee19489..0fc4771093fa 100644 --- a/composer.lock +++ b/composer.lock @@ -1,7 +1,7 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], "content-hash": "c6ae2be0f066e566e8280b2954aad257", @@ -1025,16 +1025,16 @@ }, { "name": "paragonie/random_compat", - "version": "v2.0.15", + "version": "v2.0.17", "source": { "type": "git", "url": "https://github.com/paragonie/random_compat.git", - "reference": "10bcb46e8f3d365170f6de9d05245aa066b81f09" + "reference": "29af24f25bab834fcbb38ad2a69fa93b867e070d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/paragonie/random_compat/zipball/10bcb46e8f3d365170f6de9d05245aa066b81f09", - "reference": "10bcb46e8f3d365170f6de9d05245aa066b81f09", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/29af24f25bab834fcbb38ad2a69fa93b867e070d", + "reference": "29af24f25bab834fcbb38ad2a69fa93b867e070d", "shasum": "" }, "require": { @@ -1070,7 +1070,7 @@ "pseudorandom", "random" ], - "time": "2018-06-08T15:26:40+00:00" + "time": "2018-07-04T16:31:37+00:00" }, { "name": "pelago/emogrifier", @@ -1768,16 +1768,16 @@ }, { "name": "symfony/console", - "version": "v4.1.1", + "version": "v4.1.2", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "70591cda56b4b47c55776ac78e157c4bb6c8b43f" + "reference": "5c31f6a97c1c240707f6d786e7e59bfacdbc0219" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/70591cda56b4b47c55776ac78e157c4bb6c8b43f", - "reference": "70591cda56b4b47c55776ac78e157c4bb6c8b43f", + "url": "https://api.github.com/repos/symfony/console/zipball/5c31f6a97c1c240707f6d786e7e59bfacdbc0219", + "reference": "5c31f6a97c1c240707f6d786e7e59bfacdbc0219", "shasum": "" }, "require": { @@ -1832,20 +1832,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2018-05-31T10:17:53+00:00" + "time": "2018-07-16T14:05:40+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v4.1.1", + "version": "v4.1.2", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "2391ed210a239868e7256eb6921b1bd83f3087b5" + "reference": "00d64638e4f0703a00ab7fc2c8ae5f75f3b4020f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/2391ed210a239868e7256eb6921b1bd83f3087b5", - "reference": "2391ed210a239868e7256eb6921b1bd83f3087b5", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/00d64638e4f0703a00ab7fc2c8ae5f75f3b4020f", + "reference": "00d64638e4f0703a00ab7fc2c8ae5f75f3b4020f", "shasum": "" }, "require": { @@ -1895,11 +1895,11 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2018-04-06T07:35:57+00:00" + "time": "2018-07-10T11:02:47+00:00" }, { "name": "symfony/filesystem", - "version": "v4.1.1", + "version": "v4.1.2", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", @@ -1949,7 +1949,7 @@ }, { "name": "symfony/finder", - "version": "v4.1.1", + "version": "v4.1.2", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", @@ -2112,7 +2112,7 @@ }, { "name": "symfony/process", - "version": "v4.1.1", + "version": "v4.1.2", "source": { "type": "git", "url": "https://github.com/symfony/process.git", @@ -2728,16 +2728,16 @@ }, { "name": "zendframework/zend-diactoros", - "version": "1.8.0", + "version": "1.8.3", "source": { "type": "git", "url": "https://github.com/zendframework/zend-diactoros.git", - "reference": "11c9c1835e60eef6f9234377a480fcec096ebd9e" + "reference": "72c13834fb3db2a962e913758b384ff2e6425d6e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-diactoros/zipball/11c9c1835e60eef6f9234377a480fcec096ebd9e", - "reference": "11c9c1835e60eef6f9234377a480fcec096ebd9e", + "url": "https://api.github.com/repos/zendframework/zend-diactoros/zipball/72c13834fb3db2a962e913758b384ff2e6425d6e", + "reference": "72c13834fb3db2a962e913758b384ff2e6425d6e", "shasum": "" }, "require": { @@ -2750,7 +2750,7 @@ "require-dev": { "ext-dom": "*", "ext-libxml": "*", - "phpunit/phpunit": "^5.7.16 || ^6.0.8", + "phpunit/phpunit": "^5.7.16 || ^6.0.8 || ^7.2.7", "zendframework/zend-coding-standard": "~1.0" }, "type": "library", @@ -2787,7 +2787,7 @@ "psr", "psr-7" ], - "time": "2018-06-27T18:52:43+00:00" + "time": "2018-07-24T21:54:38+00:00" }, { "name": "zendframework/zend-escaper", @@ -4667,16 +4667,16 @@ }, { "name": "friendsofphp/php-cs-fixer", - "version": "v2.12.1", + "version": "v2.12.2", "source": { "type": "git", "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", - "reference": "beef6cbe6dec7205edcd143842a49f9a691859a6" + "reference": "dcc87d5414e9d0bd316fce81a5bedb9ce720b183" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/beef6cbe6dec7205edcd143842a49f9a691859a6", - "reference": "beef6cbe6dec7205edcd143842a49f9a691859a6", + "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/dcc87d5414e9d0bd316fce81a5bedb9ce720b183", + "reference": "dcc87d5414e9d0bd316fce81a5bedb9ce720b183", "shasum": "" }, "require": { @@ -4710,7 +4710,7 @@ "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.0.1", "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.0.1", "phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1", - "phpunitgoodpractices/traits": "^1.5", + "phpunitgoodpractices/traits": "^1.5.1", "symfony/phpunit-bridge": "^4.0" }, "suggest": { @@ -4754,7 +4754,7 @@ } ], "description": "A tool to automatically fix PHP code style", - "time": "2018-06-10T08:26:56+00:00" + "time": "2018-07-06T10:37:40+00:00" }, { "name": "lusitanian/oauth", @@ -5596,16 +5596,16 @@ }, { "name": "phpunit/phpunit", - "version": "6.5.8", + "version": "6.5.9", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "4f21a3c6b97c42952fd5c2837bb354ec0199b97b" + "reference": "093ca5508174cd8ab8efe44fd1dde447adfdec8f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/4f21a3c6b97c42952fd5c2837bb354ec0199b97b", - "reference": "4f21a3c6b97c42952fd5c2837bb354ec0199b97b", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/093ca5508174cd8ab8efe44fd1dde447adfdec8f", + "reference": "093ca5508174cd8ab8efe44fd1dde447adfdec8f", "shasum": "" }, "require": { @@ -5676,20 +5676,20 @@ "testing", "xunit" ], - "time": "2018-04-10T11:38:34+00:00" + "time": "2018-07-03T06:40:40+00:00" }, { "name": "phpunit/phpunit-mock-objects", - "version": "5.0.7", + "version": "5.0.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "3eaf040f20154d27d6da59ca2c6e28ac8fd56dce" + "reference": "6f9a3c8bf34188a2b53ce2ae7a126089c53e0a9f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/3eaf040f20154d27d6da59ca2c6e28ac8fd56dce", - "reference": "3eaf040f20154d27d6da59ca2c6e28ac8fd56dce", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/6f9a3c8bf34188a2b53ce2ae7a126089c53e0a9f", + "reference": "6f9a3c8bf34188a2b53ce2ae7a126089c53e0a9f", "shasum": "" }, "require": { @@ -5735,7 +5735,7 @@ "mock", "xunit" ], - "time": "2018-05-29T13:50:43+00:00" + "time": "2018-07-13T03:27:23+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -6438,7 +6438,7 @@ }, { "name": "symfony/config", - "version": "v4.1.1", + "version": "v4.1.2", "source": { "type": "git", "url": "https://github.com/symfony/config.git", @@ -6501,16 +6501,16 @@ }, { "name": "symfony/dependency-injection", - "version": "v4.1.1", + "version": "v4.1.2", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "e761828a85d7dfc00b927f94ccbe1851ce0b6535" + "reference": "62912ab79facdbdaa0849f6c2fe4734b7b60f5cc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/e761828a85d7dfc00b927f94ccbe1851ce0b6535", - "reference": "e761828a85d7dfc00b927f94ccbe1851ce0b6535", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/62912ab79facdbdaa0849f6c2fe4734b7b60f5cc", + "reference": "62912ab79facdbdaa0849f6c2fe4734b7b60f5cc", "shasum": "" }, "require": { @@ -6568,20 +6568,20 @@ ], "description": "Symfony DependencyInjection Component", "homepage": "https://symfony.com", - "time": "2018-06-25T11:12:43+00:00" + "time": "2018-07-16T14:05:40+00:00" }, { "name": "symfony/options-resolver", - "version": "v4.1.1", + "version": "v4.1.2", "source": { "type": "git", "url": "https://github.com/symfony/options-resolver.git", - "reference": "45cdcc8a96ef92b43a50723e6d1f5f83096e8cef" + "reference": "0aec9f9c5d2447ae7ea5ea31bc82f1d43f9a8a56" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/45cdcc8a96ef92b43a50723e6d1f5f83096e8cef", - "reference": "45cdcc8a96ef92b43a50723e6d1f5f83096e8cef", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/0aec9f9c5d2447ae7ea5ea31bc82f1d43f9a8a56", + "reference": "0aec9f9c5d2447ae7ea5ea31bc82f1d43f9a8a56", "shasum": "" }, "require": { @@ -6622,7 +6622,7 @@ "configuration", "options" ], - "time": "2018-05-31T10:17:53+00:00" + "time": "2018-07-07T16:00:36+00:00" }, { "name": "symfony/polyfill-php70", @@ -6740,7 +6740,7 @@ }, { "name": "symfony/stopwatch", - "version": "v4.1.1", + "version": "v4.1.2", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", From 141c9209da8b96abd0f5999b2e5bc3b4aee2c370 Mon Sep 17 00:00:00 2001 From: Yaroslav Rogoza Date: Sun, 5 Aug 2018 16:22:41 +0200 Subject: [PATCH 05/13] Return hashed cart id for both cases: logged in customer and guest --- .../Model/Resolver/Cart/CreateEmptyCart.php | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart/CreateEmptyCart.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart/CreateEmptyCart.php index 1c24465e8937..1b6e4d1bebde 100644 --- a/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart/CreateEmptyCart.php +++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart/CreateEmptyCart.php @@ -7,14 +7,16 @@ namespace Magento\QuoteGraphQl\Model\Resolver\Cart; +use Magento\Authorization\Model\UserContextInterface; +use Magento\Framework\GraphQl\Config\Element\Field; use Magento\Framework\GraphQl\Query\Resolver\Value; use Magento\Framework\GraphQl\Query\Resolver\ValueFactory; -use Magento\Framework\GraphQl\Config\Element\Field; use Magento\Framework\GraphQl\Query\ResolverInterface; use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; -use Magento\Quote\Api\GuestCartManagementInterface; use Magento\Quote\Api\CartManagementInterface; -use Magento\Authorization\Model\UserContextInterface; +use Magento\Quote\Api\GuestCartManagementInterface; +use Magento\Quote\Model\QuoteIdMask; +use Magento\Quote\Model\QuoteIdMaskFactory; /** * {@inheritdoc} @@ -36,6 +38,11 @@ class CreateEmptyCart implements ResolverInterface */ private $valueFactory; + /** + * @var QuoteIdMaskFactory + */ + private $quoteIdMaskFactory; + /** * @var UserContextInterface */ @@ -46,17 +53,20 @@ class CreateEmptyCart implements ResolverInterface * @param GuestCartManagementInterface $guestCartManagement * @param ValueFactory $valueFactory * @param UserContextInterface $userContext + * @param QuoteIdMaskFactory $quoteIdMaskFactory */ public function __construct( CartManagementInterface $cartManagement, GuestCartManagementInterface $guestCartManagement, ValueFactory $valueFactory, - UserContextInterface $userContext + UserContextInterface $userContext, + QuoteIdMaskFactory $quoteIdMaskFactory ) { $this->cartManagement = $cartManagement; $this->guestCartManagement = $guestCartManagement; $this->valueFactory = $valueFactory; $this->userContext = $userContext; + $this->quoteIdMaskFactory = $quoteIdMaskFactory; } /** @@ -68,6 +78,10 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value if ($customerId) { $cartId = $this->cartManagement->createEmptyCartForCustomer($customerId); + /** @var QuoteIdMask $quoteIdMask */ + $quoteIdMask = $this->quoteIdMaskFactory->create(); + $quoteIdMask->setQuoteId($cartId)->save(); + $cartId = $quoteIdMask->getMaskedId(); } else { $cartId = $this->guestCartManagement->createEmptyCart(); } From fcd809ed284e8efc443711b07e58ccf814031551 Mon Sep 17 00:00:00 2001 From: Yaroslav Rogoza Date: Sun, 5 Aug 2018 16:27:25 +0200 Subject: [PATCH 06/13] Optimized usage of user context --- .../Model/Resolver/Cart/CreateEmptyCart.php | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart/CreateEmptyCart.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart/CreateEmptyCart.php index 1b6e4d1bebde..e936ff82ad29 100644 --- a/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart/CreateEmptyCart.php +++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart/CreateEmptyCart.php @@ -7,7 +7,6 @@ namespace Magento\QuoteGraphQl\Model\Resolver\Cart; -use Magento\Authorization\Model\UserContextInterface; use Magento\Framework\GraphQl\Config\Element\Field; use Magento\Framework\GraphQl\Query\Resolver\Value; use Magento\Framework\GraphQl\Query\Resolver\ValueFactory; @@ -43,29 +42,21 @@ class CreateEmptyCart implements ResolverInterface */ private $quoteIdMaskFactory; - /** - * @var UserContextInterface - */ - private $userContext; - /** * @param CartManagementInterface $cartManagement * @param GuestCartManagementInterface $guestCartManagement * @param ValueFactory $valueFactory - * @param UserContextInterface $userContext * @param QuoteIdMaskFactory $quoteIdMaskFactory */ public function __construct( CartManagementInterface $cartManagement, GuestCartManagementInterface $guestCartManagement, ValueFactory $valueFactory, - UserContextInterface $userContext, QuoteIdMaskFactory $quoteIdMaskFactory ) { $this->cartManagement = $cartManagement; $this->guestCartManagement = $guestCartManagement; $this->valueFactory = $valueFactory; - $this->userContext = $userContext; $this->quoteIdMaskFactory = $quoteIdMaskFactory; } @@ -74,7 +65,7 @@ public function __construct( */ public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null) : Value { - $customerId = $this->userContext->getUserId(); + $customerId = $context->getUserId(); if ($customerId) { $cartId = $this->cartManagement->createEmptyCartForCustomer($customerId); From 348e9b81884551a0dca84da8ff52c58b43605035 Mon Sep 17 00:00:00 2001 From: Yaroslav Rogoza Date: Sun, 5 Aug 2018 16:30:10 +0200 Subject: [PATCH 07/13] Added quote dependency --- app/code/Magento/QuoteGraphQl/composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/QuoteGraphQl/composer.json b/app/code/Magento/QuoteGraphQl/composer.json index cc31a8b83489..76ecfac373ef 100644 --- a/app/code/Magento/QuoteGraphQl/composer.json +++ b/app/code/Magento/QuoteGraphQl/composer.json @@ -5,7 +5,8 @@ "require": { "php": "~7.1.3||~7.2.0", "magento/framework": "*", - "magento/module-authorization": "*" + "magento/module-authorization": "*", + "magento/module-quote": "*" }, "suggest": { "magento/module-graph-ql": "*", From 52f706949261caee3a59da57cb2b4d642af4f608 Mon Sep 17 00:00:00 2001 From: Yaroslav Rogoza Date: Sun, 5 Aug 2018 16:31:39 +0200 Subject: [PATCH 08/13] updating composer.lock file --- composer.lock | 294 +++++++++++++++++++++----------------------------- 1 file changed, 123 insertions(+), 171 deletions(-) diff --git a/composer.lock b/composer.lock index 0fc4771093fa..0ca7e7ff1a68 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "c6ae2be0f066e566e8280b2954aad257", + "content-hash": "1a00a0d3f916f417691ce75c69403709", "packages": [ { "name": "braintree/braintree_php", @@ -257,26 +257,26 @@ }, { "name": "composer/composer", - "version": "1.6.5", + "version": "1.7.0", "source": { "type": "git", "url": "https://github.com/composer/composer.git", - "reference": "b184a92419cc9a9c4c6a09db555a94d441cb11c9" + "reference": "39edb2f375679a4eba19e69e9c9491e302976983" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/composer/zipball/b184a92419cc9a9c4c6a09db555a94d441cb11c9", - "reference": "b184a92419cc9a9c4c6a09db555a94d441cb11c9", + "url": "https://api.github.com/repos/composer/composer/zipball/39edb2f375679a4eba19e69e9c9491e302976983", + "reference": "39edb2f375679a4eba19e69e9c9491e302976983", "shasum": "" }, "require": { "composer/ca-bundle": "^1.0", "composer/semver": "^1.0", "composer/spdx-licenses": "^1.2", + "composer/xdebug-handler": "^1.1", "justinrainbow/json-schema": "^3.0 || ^4.0 || ^5.0", "php": "^5.3.2 || ^7.0", "psr/log": "^1.0", - "seld/cli-prompt": "^1.0", "seld/jsonlint": "^1.4", "seld/phar-utils": "^1.0", "symfony/console": "^2.7 || ^3.0 || ^4.0", @@ -302,7 +302,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.6-dev" + "dev-master": "1.7-dev" } }, "autoload": { @@ -333,7 +333,7 @@ "dependency", "package" ], - "time": "2018-05-04T09:44:59+00:00" + "time": "2018-08-03T13:39:07+00:00" }, { "name": "composer/semver", @@ -458,6 +458,50 @@ ], "time": "2018-04-30T10:33:04+00:00" }, + { + "name": "composer/xdebug-handler", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/composer/xdebug-handler.git", + "reference": "c919dc6c62e221fc6406f861ea13433c0aa24f08" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/c919dc6c62e221fc6406f861ea13433c0aa24f08", + "reference": "c919dc6c62e221fc6406f861ea13433c0aa24f08", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0", + "psr/log": "^1.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Composer\\XdebugHandler\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "John Stevenson", + "email": "john-stevenson@blueyonder.co.uk" + } + ], + "description": "Restarts a process without xdebug.", + "keywords": [ + "Xdebug", + "performance" + ], + "time": "2018-04-11T15:42:36+00:00" + }, { "name": "container-interop/container-interop", "version": "1.2.0", @@ -546,16 +590,16 @@ }, { "name": "guzzlehttp/ringphp", - "version": "1.1.0", + "version": "1.1.1", "source": { "type": "git", "url": "https://github.com/guzzle/RingPHP.git", - "reference": "dbbb91d7f6c191e5e405e900e3102ac7f261bc0b" + "reference": "5e2a174052995663dd68e6b5ad838afd47dd615b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/RingPHP/zipball/dbbb91d7f6c191e5e405e900e3102ac7f261bc0b", - "reference": "dbbb91d7f6c191e5e405e900e3102ac7f261bc0b", + "url": "https://api.github.com/repos/guzzle/RingPHP/zipball/5e2a174052995663dd68e6b5ad838afd47dd615b", + "reference": "5e2a174052995663dd68e6b5ad838afd47dd615b", "shasum": "" }, "require": { @@ -593,7 +637,7 @@ } ], "description": "Provides a simple API and specification that abstracts away the details of HTTP into a single PHP function.", - "time": "2015-05-20T03:37:09+00:00" + "time": "2018-07-31T13:22:33+00:00" }, { "name": "guzzlehttp/streams", @@ -1625,54 +1669,6 @@ ], "time": "2018-06-13T15:59:06+00:00" }, - { - "name": "seld/cli-prompt", - "version": "1.0.3", - "source": { - "type": "git", - "url": "https://github.com/Seldaek/cli-prompt.git", - "reference": "a19a7376a4689d4d94cab66ab4f3c816019ba8dd" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Seldaek/cli-prompt/zipball/a19a7376a4689d4d94cab66ab4f3c816019ba8dd", - "reference": "a19a7376a4689d4d94cab66ab4f3c816019ba8dd", - "shasum": "" - }, - "require": { - "php": ">=5.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Seld\\CliPrompt\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jordi Boggiano", - "email": "j.boggiano@seld.be" - } - ], - "description": "Allows you to prompt for user input on the command line, and optionally hide the characters they type", - "keywords": [ - "cli", - "console", - "hidden", - "input", - "prompt" - ], - "time": "2017-03-18T11:32:45+00:00" - }, { "name": "seld/jsonlint", "version": "1.7.1", @@ -1768,16 +1764,16 @@ }, { "name": "symfony/console", - "version": "v4.1.2", + "version": "v4.1.3", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "5c31f6a97c1c240707f6d786e7e59bfacdbc0219" + "reference": "ca80b8ced97cf07390078b29773dc384c39eee1f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/5c31f6a97c1c240707f6d786e7e59bfacdbc0219", - "reference": "5c31f6a97c1c240707f6d786e7e59bfacdbc0219", + "url": "https://api.github.com/repos/symfony/console/zipball/ca80b8ced97cf07390078b29773dc384c39eee1f", + "reference": "ca80b8ced97cf07390078b29773dc384c39eee1f", "shasum": "" }, "require": { @@ -1832,20 +1828,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2018-07-16T14:05:40+00:00" + "time": "2018-07-26T11:24:31+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v4.1.2", + "version": "v4.1.3", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "00d64638e4f0703a00ab7fc2c8ae5f75f3b4020f" + "reference": "bfb30c2ad377615a463ebbc875eba64a99f6aa3e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/00d64638e4f0703a00ab7fc2c8ae5f75f3b4020f", - "reference": "00d64638e4f0703a00ab7fc2c8ae5f75f3b4020f", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/bfb30c2ad377615a463ebbc875eba64a99f6aa3e", + "reference": "bfb30c2ad377615a463ebbc875eba64a99f6aa3e", "shasum": "" }, "require": { @@ -1895,20 +1891,20 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2018-07-10T11:02:47+00:00" + "time": "2018-07-26T09:10:45+00:00" }, { "name": "symfony/filesystem", - "version": "v4.1.2", + "version": "v4.1.3", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "562bf7005b55fd80d26b582d28e3e10f2dd5ae9c" + "reference": "2e30335e0aafeaa86645555959572fe7cea22b43" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/562bf7005b55fd80d26b582d28e3e10f2dd5ae9c", - "reference": "562bf7005b55fd80d26b582d28e3e10f2dd5ae9c", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/2e30335e0aafeaa86645555959572fe7cea22b43", + "reference": "2e30335e0aafeaa86645555959572fe7cea22b43", "shasum": "" }, "require": { @@ -1945,20 +1941,20 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2018-05-30T07:26:09+00:00" + "time": "2018-07-26T11:24:31+00:00" }, { "name": "symfony/finder", - "version": "v4.1.2", + "version": "v4.1.3", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "84714b8417d19e4ba02ea78a41a975b3efaafddb" + "reference": "e162f1df3102d0b7472805a5a9d5db9fcf0a8068" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/84714b8417d19e4ba02ea78a41a975b3efaafddb", - "reference": "84714b8417d19e4ba02ea78a41a975b3efaafddb", + "url": "https://api.github.com/repos/symfony/finder/zipball/e162f1df3102d0b7472805a5a9d5db9fcf0a8068", + "reference": "e162f1df3102d0b7472805a5a9d5db9fcf0a8068", "shasum": "" }, "require": { @@ -1994,7 +1990,7 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2018-06-19T21:38:16+00:00" + "time": "2018-07-26T11:24:31+00:00" }, { "name": "symfony/polyfill-ctype", @@ -2112,16 +2108,16 @@ }, { "name": "symfony/process", - "version": "v4.1.2", + "version": "v4.1.3", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "1d1677391ecf00d1c5b9482d6050c0c27aa3ac3a" + "reference": "f01fc7a4493572f7f506c49dcb50ad01fb3a2f56" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/1d1677391ecf00d1c5b9482d6050c0c27aa3ac3a", - "reference": "1d1677391ecf00d1c5b9482d6050c0c27aa3ac3a", + "url": "https://api.github.com/repos/symfony/process/zipball/f01fc7a4493572f7f506c49dcb50ad01fb3a2f56", + "reference": "f01fc7a4493572f7f506c49dcb50ad01fb3a2f56", "shasum": "" }, "require": { @@ -2157,7 +2153,7 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2018-05-31T10:17:53+00:00" + "time": "2018-07-26T11:24:31+00:00" }, { "name": "tedivm/jshrink", @@ -2728,16 +2724,16 @@ }, { "name": "zendframework/zend-diactoros", - "version": "1.8.3", + "version": "1.8.4", "source": { "type": "git", "url": "https://github.com/zendframework/zend-diactoros.git", - "reference": "72c13834fb3db2a962e913758b384ff2e6425d6e" + "reference": "736ffa7c2bfa4a60e8a10acb316fa2ac456c5fba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-diactoros/zipball/72c13834fb3db2a962e913758b384ff2e6425d6e", - "reference": "72c13834fb3db2a962e913758b384ff2e6425d6e", + "url": "https://api.github.com/repos/zendframework/zend-diactoros/zipball/736ffa7c2bfa4a60e8a10acb316fa2ac456c5fba", + "reference": "736ffa7c2bfa4a60e8a10acb316fa2ac456c5fba", "shasum": "" }, "require": { @@ -2787,7 +2783,7 @@ "psr", "psr-7" ], - "time": "2018-07-24T21:54:38+00:00" + "time": "2018-08-01T13:47:49+00:00" }, { "name": "zendframework/zend-escaper", @@ -2883,16 +2879,16 @@ }, { "name": "zendframework/zend-feed", - "version": "2.10.2", + "version": "2.10.3", "source": { "type": "git", "url": "https://github.com/zendframework/zend-feed.git", - "reference": "5253f949f4ad999086ab9b408908b6c6776f24db" + "reference": "6641f4cf3f4586c63f83fd70b6d19966025c8888" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-feed/zipball/5253f949f4ad999086ab9b408908b6c6776f24db", - "reference": "5253f949f4ad999086ab9b408908b6c6776f24db", + "url": "https://api.github.com/repos/zendframework/zend-feed/zipball/6641f4cf3f4586c63f83fd70b6d19966025c8888", + "reference": "6641f4cf3f4586c63f83fd70b6d19966025c8888", "shasum": "" }, "require": { @@ -2940,7 +2936,7 @@ "feed", "zf" ], - "time": "2018-06-18T20:14:01+00:00" + "time": "2018-08-01T13:53:20+00:00" }, { "name": "zendframework/zend-filter", @@ -3085,16 +3081,16 @@ }, { "name": "zendframework/zend-http", - "version": "2.8.0", + "version": "2.8.1", "source": { "type": "git", "url": "https://github.com/zendframework/zend-http.git", - "reference": "f48b276ffa11b48dd1ae3c6bc306d6ed7958ef51" + "reference": "44197164a270259116162a442f639085ea24094a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zendframework/zend-http/zipball/f48b276ffa11b48dd1ae3c6bc306d6ed7958ef51", - "reference": "f48b276ffa11b48dd1ae3c6bc306d6ed7958ef51", + "url": "https://api.github.com/repos/zendframework/zend-http/zipball/44197164a270259116162a442f639085ea24094a", + "reference": "44197164a270259116162a442f639085ea24094a", "shasum": "" }, "require": { @@ -3136,7 +3132,7 @@ "zend", "zf" ], - "time": "2018-04-26T21:04:50+00:00" + "time": "2018-08-01T13:50:48+00:00" }, { "name": "zendframework/zend-hydrator", @@ -4445,50 +4441,6 @@ } ], "packages-dev": [ - { - "name": "composer/xdebug-handler", - "version": "1.1.0", - "source": { - "type": "git", - "url": "https://github.com/composer/xdebug-handler.git", - "reference": "c919dc6c62e221fc6406f861ea13433c0aa24f08" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/c919dc6c62e221fc6406f861ea13433c0aa24f08", - "reference": "c919dc6c62e221fc6406f861ea13433c0aa24f08", - "shasum": "" - }, - "require": { - "php": "^5.3.2 || ^7.0", - "psr/log": "^1.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5" - }, - "type": "library", - "autoload": { - "psr-4": { - "Composer\\XdebugHandler\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "John Stevenson", - "email": "john-stevenson@blueyonder.co.uk" - } - ], - "description": "Restarts a process without xdebug.", - "keywords": [ - "Xdebug", - "performance" - ], - "time": "2018-04-11T15:42:36+00:00" - }, { "name": "doctrine/annotations", "version": "v1.6.0", @@ -5596,16 +5548,16 @@ }, { "name": "phpunit/phpunit", - "version": "6.5.9", + "version": "6.5.10", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "093ca5508174cd8ab8efe44fd1dde447adfdec8f" + "reference": "5744955af9c0a2de74a5eb5287c50bf025100d39" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/093ca5508174cd8ab8efe44fd1dde447adfdec8f", - "reference": "093ca5508174cd8ab8efe44fd1dde447adfdec8f", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/5744955af9c0a2de74a5eb5287c50bf025100d39", + "reference": "5744955af9c0a2de74a5eb5287c50bf025100d39", "shasum": "" }, "require": { @@ -5623,7 +5575,7 @@ "phpunit/php-file-iterator": "^1.4.3", "phpunit/php-text-template": "^1.2.1", "phpunit/php-timer": "^1.0.9", - "phpunit/phpunit-mock-objects": "^5.0.5", + "phpunit/phpunit-mock-objects": "^5.0.8", "sebastian/comparator": "^2.1", "sebastian/diff": "^2.0", "sebastian/environment": "^3.1", @@ -5676,7 +5628,7 @@ "testing", "xunit" ], - "time": "2018-07-03T06:40:40+00:00" + "time": "2018-08-03T05:27:14+00:00" }, { "name": "phpunit/phpunit-mock-objects", @@ -6438,16 +6390,16 @@ }, { "name": "symfony/config", - "version": "v4.1.2", + "version": "v4.1.3", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "e57e7b573df9d0eaa8c0152768c708ee7ea2b8e5" + "reference": "c868972ac26e4e19860ce11b300bb74145246ff9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/e57e7b573df9d0eaa8c0152768c708ee7ea2b8e5", - "reference": "e57e7b573df9d0eaa8c0152768c708ee7ea2b8e5", + "url": "https://api.github.com/repos/symfony/config/zipball/c868972ac26e4e19860ce11b300bb74145246ff9", + "reference": "c868972ac26e4e19860ce11b300bb74145246ff9", "shasum": "" }, "require": { @@ -6497,20 +6449,20 @@ ], "description": "Symfony Config Component", "homepage": "https://symfony.com", - "time": "2018-06-20T11:15:17+00:00" + "time": "2018-07-26T11:24:31+00:00" }, { "name": "symfony/dependency-injection", - "version": "v4.1.2", + "version": "v4.1.3", "source": { "type": "git", "url": "https://github.com/symfony/dependency-injection.git", - "reference": "62912ab79facdbdaa0849f6c2fe4734b7b60f5cc" + "reference": "f4f401fc2766eb8d766fc6043d9e6489b37a41e4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/62912ab79facdbdaa0849f6c2fe4734b7b60f5cc", - "reference": "62912ab79facdbdaa0849f6c2fe4734b7b60f5cc", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/f4f401fc2766eb8d766fc6043d9e6489b37a41e4", + "reference": "f4f401fc2766eb8d766fc6043d9e6489b37a41e4", "shasum": "" }, "require": { @@ -6568,20 +6520,20 @@ ], "description": "Symfony DependencyInjection Component", "homepage": "https://symfony.com", - "time": "2018-07-16T14:05:40+00:00" + "time": "2018-08-01T08:24:03+00:00" }, { "name": "symfony/options-resolver", - "version": "v4.1.2", + "version": "v4.1.3", "source": { "type": "git", "url": "https://github.com/symfony/options-resolver.git", - "reference": "0aec9f9c5d2447ae7ea5ea31bc82f1d43f9a8a56" + "reference": "1913f1962477cdbb13df951f8147d5da1fe2412c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/0aec9f9c5d2447ae7ea5ea31bc82f1d43f9a8a56", - "reference": "0aec9f9c5d2447ae7ea5ea31bc82f1d43f9a8a56", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/1913f1962477cdbb13df951f8147d5da1fe2412c", + "reference": "1913f1962477cdbb13df951f8147d5da1fe2412c", "shasum": "" }, "require": { @@ -6622,7 +6574,7 @@ "configuration", "options" ], - "time": "2018-07-07T16:00:36+00:00" + "time": "2018-07-26T08:55:25+00:00" }, { "name": "symfony/polyfill-php70", @@ -6740,16 +6692,16 @@ }, { "name": "symfony/stopwatch", - "version": "v4.1.2", + "version": "v4.1.3", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", - "reference": "07463bbbbbfe119045a24c4a516f92ebd2752784" + "reference": "966c982df3cca41324253dc0c7ffe76b6076b705" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/07463bbbbbfe119045a24c4a516f92ebd2752784", - "reference": "07463bbbbbfe119045a24c4a516f92ebd2752784", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/966c982df3cca41324253dc0c7ffe76b6076b705", + "reference": "966c982df3cca41324253dc0c7ffe76b6076b705", "shasum": "" }, "require": { @@ -6785,7 +6737,7 @@ ], "description": "Symfony Stopwatch Component", "homepage": "https://symfony.com", - "time": "2018-02-19T16:51:42+00:00" + "time": "2018-07-26T11:00:49+00:00" }, { "name": "theseer/fdomdocument", From 131d1e4094d31f6978765bc7018336b94ec1cdf5 Mon Sep 17 00:00:00 2001 From: Yaroslav Rogoza Date: Sun, 5 Aug 2018 18:59:48 +0200 Subject: [PATCH 09/13] Removed authorization module dependency after recent optimizations --- app/code/Magento/QuoteGraphQl/composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/app/code/Magento/QuoteGraphQl/composer.json b/app/code/Magento/QuoteGraphQl/composer.json index 76ecfac373ef..3771ecfc4bcc 100644 --- a/app/code/Magento/QuoteGraphQl/composer.json +++ b/app/code/Magento/QuoteGraphQl/composer.json @@ -5,7 +5,6 @@ "require": { "php": "~7.1.3||~7.2.0", "magento/framework": "*", - "magento/module-authorization": "*", "magento/module-quote": "*" }, "suggest": { From 09ed1b82fa33b1189d1fd4f0325c8b12041634bd Mon Sep 17 00:00:00 2001 From: Yaroslav Rogoza Date: Thu, 9 Aug 2018 12:37:14 +0200 Subject: [PATCH 10/13] Inject user context instead of using global implementation --- .../Model/Resolver/Cart/CreateEmptyCart.php | 11 ++- app/code/Magento/QuoteGraphQl/composer.json | 1 + composer.lock | 78 +++++++++++-------- 3 files changed, 55 insertions(+), 35 deletions(-) diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart/CreateEmptyCart.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart/CreateEmptyCart.php index e936ff82ad29..1b6e4d1bebde 100644 --- a/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart/CreateEmptyCart.php +++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart/CreateEmptyCart.php @@ -7,6 +7,7 @@ namespace Magento\QuoteGraphQl\Model\Resolver\Cart; +use Magento\Authorization\Model\UserContextInterface; use Magento\Framework\GraphQl\Config\Element\Field; use Magento\Framework\GraphQl\Query\Resolver\Value; use Magento\Framework\GraphQl\Query\Resolver\ValueFactory; @@ -42,21 +43,29 @@ class CreateEmptyCart implements ResolverInterface */ private $quoteIdMaskFactory; + /** + * @var UserContextInterface + */ + private $userContext; + /** * @param CartManagementInterface $cartManagement * @param GuestCartManagementInterface $guestCartManagement * @param ValueFactory $valueFactory + * @param UserContextInterface $userContext * @param QuoteIdMaskFactory $quoteIdMaskFactory */ public function __construct( CartManagementInterface $cartManagement, GuestCartManagementInterface $guestCartManagement, ValueFactory $valueFactory, + UserContextInterface $userContext, QuoteIdMaskFactory $quoteIdMaskFactory ) { $this->cartManagement = $cartManagement; $this->guestCartManagement = $guestCartManagement; $this->valueFactory = $valueFactory; + $this->userContext = $userContext; $this->quoteIdMaskFactory = $quoteIdMaskFactory; } @@ -65,7 +74,7 @@ public function __construct( */ public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null) : Value { - $customerId = $context->getUserId(); + $customerId = $this->userContext->getUserId(); if ($customerId) { $cartId = $this->cartManagement->createEmptyCartForCustomer($customerId); diff --git a/app/code/Magento/QuoteGraphQl/composer.json b/app/code/Magento/QuoteGraphQl/composer.json index 3771ecfc4bcc..76ecfac373ef 100644 --- a/app/code/Magento/QuoteGraphQl/composer.json +++ b/app/code/Magento/QuoteGraphQl/composer.json @@ -5,6 +5,7 @@ "require": { "php": "~7.1.3||~7.2.0", "magento/framework": "*", + "magento/module-authorization": "*", "magento/module-quote": "*" }, "suggest": { diff --git a/composer.lock b/composer.lock index 430b233d72fc..9a418e77c5ef 100644 --- a/composer.lock +++ b/composer.lock @@ -1,10 +1,10 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "57ae7ad75c4d8d50eb40e4ffe0fd2740", + "content-hash": "d7239b33ec2e6826b82dc8a9e756abff", "packages": [ { "name": "braintree/braintree_php", @@ -201,16 +201,16 @@ }, { "name": "composer/ca-bundle", - "version": "1.1.1", + "version": "1.1.2", "source": { "type": "git", "url": "https://github.com/composer/ca-bundle.git", - "reference": "d2c0a83b7533d6912e8d516756ebd34f893e9169" + "reference": "46afded9720f40b9dc63542af4e3e43a1177acb0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/ca-bundle/zipball/d2c0a83b7533d6912e8d516756ebd34f893e9169", - "reference": "d2c0a83b7533d6912e8d516756ebd34f893e9169", + "url": "https://api.github.com/repos/composer/ca-bundle/zipball/46afded9720f40b9dc63542af4e3e43a1177acb0", + "reference": "46afded9720f40b9dc63542af4e3e43a1177acb0", "shasum": "" }, "require": { @@ -253,20 +253,20 @@ "ssl", "tls" ], - "time": "2018-03-29T19:57:20+00:00" + "time": "2018-08-08T08:57:40+00:00" }, { "name": "composer/composer", - "version": "1.7.0", + "version": "1.7.1", "source": { "type": "git", "url": "https://github.com/composer/composer.git", - "reference": "39edb2f375679a4eba19e69e9c9491e302976983" + "reference": "5d9311d4555787c8a57fea15f82471499aedf712" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/composer/zipball/39edb2f375679a4eba19e69e9c9491e302976983", - "reference": "39edb2f375679a4eba19e69e9c9491e302976983", + "url": "https://api.github.com/repos/composer/composer/zipball/5d9311d4555787c8a57fea15f82471499aedf712", + "reference": "5d9311d4555787c8a57fea15f82471499aedf712", "shasum": "" }, "require": { @@ -333,7 +333,7 @@ "dependency", "package" ], - "time": "2018-08-03T13:39:07+00:00" + "time": "2018-08-07T07:39:23+00:00" }, { "name": "composer/semver", @@ -884,6 +884,13 @@ "reference": "68522e5768edc8e829d1f64b620a3de3753f1141", "shasum": "" }, + "archive": { + "exclude": [ + "/demos", + "/documentation", + "/tests" + ] + }, "require": { "php": ">=5.2.11" }, @@ -902,7 +909,6 @@ "Zend_": "library/" } }, - "notification-url": "https://packagist.org/downloads/", "include-path": [ "library/" ], @@ -912,10 +918,14 @@ "description": "Magento Zend Framework 1", "homepage": "http://framework.zend.com/", "keywords": [ - "ZF1", - "framework" + "framework", + "zf1" ], - "time": "2018-04-06T18:49:03+00:00" + "support": { + "source": "https://github.com/magento-engcom/zf1-php-7.2-support/tree/master", + "issues": "https://github.com/magento-engcom/zf1-php-7.2-support/issues" + }, + "time": "2018-04-06T17:12:22+00:00" }, { "name": "monolog/monolog", @@ -4777,16 +4787,16 @@ }, { "name": "consolidation/config", - "version": "1.0.11", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/consolidation/config.git", - "reference": "ede41d946078e97e7a9513aadc3352f1c26817af" + "reference": "c9fc25e9088a708637e18a256321addc0670e578" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/consolidation/config/zipball/ede41d946078e97e7a9513aadc3352f1c26817af", - "reference": "ede41d946078e97e7a9513aadc3352f1c26817af", + "url": "https://api.github.com/repos/consolidation/config/zipball/c9fc25e9088a708637e18a256321addc0670e578", + "reference": "c9fc25e9088a708637e18a256321addc0670e578", "shasum": "" }, "require": { @@ -4796,7 +4806,7 @@ }, "require-dev": { "g1a/composer-test-scenarios": "^1", - "phpunit/phpunit": "^4", + "phpunit/phpunit": "^5", "satooshi/php-coveralls": "^1.0", "squizlabs/php_codesniffer": "2.*", "symfony/console": "^2.5|^3|^4", @@ -4827,7 +4837,7 @@ } ], "description": "Provide configuration services for a commandline tool.", - "time": "2018-05-27T01:17:02+00:00" + "time": "2018-08-07T22:57:00+00:00" }, { "name": "consolidation/log", @@ -7218,16 +7228,16 @@ }, { "name": "phpunit/phpunit", - "version": "6.5.10", + "version": "6.5.11", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "5744955af9c0a2de74a5eb5287c50bf025100d39" + "reference": "7bab54cb366076023bbf457a2a0d513332cd40f2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/5744955af9c0a2de74a5eb5287c50bf025100d39", - "reference": "5744955af9c0a2de74a5eb5287c50bf025100d39", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/7bab54cb366076023bbf457a2a0d513332cd40f2", + "reference": "7bab54cb366076023bbf457a2a0d513332cd40f2", "shasum": "" }, "require": { @@ -7245,7 +7255,7 @@ "phpunit/php-file-iterator": "^1.4.3", "phpunit/php-text-template": "^1.2.1", "phpunit/php-timer": "^1.0.9", - "phpunit/phpunit-mock-objects": "^5.0.8", + "phpunit/phpunit-mock-objects": "^5.0.9", "sebastian/comparator": "^2.1", "sebastian/diff": "^2.0", "sebastian/environment": "^3.1", @@ -7298,20 +7308,20 @@ "testing", "xunit" ], - "time": "2018-08-03T05:27:14+00:00" + "time": "2018-08-07T07:05:35+00:00" }, { "name": "phpunit/phpunit-mock-objects", - "version": "5.0.8", + "version": "5.0.10", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "6f9a3c8bf34188a2b53ce2ae7a126089c53e0a9f" + "reference": "cd1cf05c553ecfec36b170070573e540b67d3f1f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/6f9a3c8bf34188a2b53ce2ae7a126089c53e0a9f", - "reference": "6f9a3c8bf34188a2b53ce2ae7a126089c53e0a9f", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/cd1cf05c553ecfec36b170070573e540b67d3f1f", + "reference": "cd1cf05c553ecfec36b170070573e540b67d3f1f", "shasum": "" }, "require": { @@ -7324,7 +7334,7 @@ "phpunit/phpunit": "<6.0" }, "require-dev": { - "phpunit/phpunit": "^6.5" + "phpunit/phpunit": "^6.5.11" }, "suggest": { "ext-soap": "*" @@ -7357,7 +7367,7 @@ "mock", "xunit" ], - "time": "2018-07-13T03:27:23+00:00" + "time": "2018-08-09T05:50:03+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", From 8fe1e21e70f0e28b159206986916990ff447453a Mon Sep 17 00:00:00 2001 From: Yaroslav Rogoza Date: Fri, 10 Aug 2018 11:40:15 +0200 Subject: [PATCH 11/13] Api-functional tests added --- .../GraphQl/Quote/CreateEmptyCartTest.php | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/CreateEmptyCartTest.php diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/CreateEmptyCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/CreateEmptyCartTest.php new file mode 100644 index 000000000000..6e819b523ec8 --- /dev/null +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/CreateEmptyCartTest.php @@ -0,0 +1,91 @@ +objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $this->quoteIdMask = $this->objectManager->create(QuoteIdMask::class); + $this->guestCartRepository = $this->objectManager->create(GuestCartRepositoryInterface::class); + } + + public function testCreateEmptyCartForGuest() + { + $query = <<graphQlQuery($query); + + self::assertArrayHasKey('createEmptyCart', $response); + + $maskedCartId = $response['createEmptyCart']; + /** @var CartInterface $guestCart */ + $guestCart = $this->guestCartRepository->get($maskedCartId); + + self::assertNotNull($guestCart->getId()); + self::assertNull($guestCart->getCustomer()->getId()); + } + + /** + * @magentoApiDataFixture Magento/Customer/_files/customer.php + */ + public function testCreateEmptyCartForRegisteredCustomer() + { + $query = <<objectManager->create( + \Magento\Integration\Api\CustomerTokenServiceInterface::class + ); + $customerToken = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); + $headerMap = ['Authorization' => 'Bearer ' . $customerToken]; + + $response = $this->graphQlQuery($query, [], '', $headerMap); + + self::assertArrayHasKey('createEmptyCart', $response); + + $maskedCartId = $response['createEmptyCart']; + /* guestCartRepository is used for registered customer to get the cart hash */ + $guestCart = $this->guestCartRepository->get($maskedCartId); + + self::assertNotNull($guestCart->getId()); + self::assertEquals(1, $guestCart->getCustomer()->getId()); + } +} From 3176de0129414f9d7b94d5d19be80c1830fa16ad Mon Sep 17 00:00:00 2001 From: Yaroslav Rogoza Date: Tue, 21 Aug 2018 19:45:38 +0300 Subject: [PATCH 12/13] Introduced API for working with quote masked id --- .../Quote/Model/MaskedQuoteIdToQuoteId.php | 57 +++++++++++++++++++ .../Model/MaskedQuoteIdToQuoteIdInterface.php | 24 ++++++++ .../Quote/Model/QuoteIdToMaskedQuoteId.php | 49 ++++++++++++++++ .../Model/QuoteIdToMaskedQuoteIdInterface.php | 24 ++++++++ app/code/Magento/Quote/etc/di.xml | 2 + .../Model/Resolver/Cart/CreateEmptyCart.php | 26 ++++----- .../Model/MaskedQUoteIdToQuoteIdTest.php | 46 +++++++++++++++ .../Model/QuoteIdToMaskedQuoteIdTest.php | 56 ++++++++++++++++++ 8 files changed, 269 insertions(+), 15 deletions(-) create mode 100644 app/code/Magento/Quote/Model/MaskedQuoteIdToQuoteId.php create mode 100644 app/code/Magento/Quote/Model/MaskedQuoteIdToQuoteIdInterface.php create mode 100644 app/code/Magento/Quote/Model/QuoteIdToMaskedQuoteId.php create mode 100644 app/code/Magento/Quote/Model/QuoteIdToMaskedQuoteIdInterface.php create mode 100644 dev/tests/integration/testsuite/Magento/Quote/Model/MaskedQUoteIdToQuoteIdTest.php create mode 100644 dev/tests/integration/testsuite/Magento/Quote/Model/QuoteIdToMaskedQuoteIdTest.php diff --git a/app/code/Magento/Quote/Model/MaskedQuoteIdToQuoteId.php b/app/code/Magento/Quote/Model/MaskedQuoteIdToQuoteId.php new file mode 100644 index 000000000000..1eefef23c7ad --- /dev/null +++ b/app/code/Magento/Quote/Model/MaskedQuoteIdToQuoteId.php @@ -0,0 +1,57 @@ +quoteIdMaskFactory = $quoteIdMaskFactory; + $this->cartRepository = $cartRepository; + $this->quoteIdMaskResource = $quoteIdMaskResource; + } + + /** + * {@inheritDoc} + */ + public function execute(string $maskedQuoteId): int + { + $quoteIdMask = $this->quoteIdMaskFactory->create(); + $this->quoteIdMaskResource->load($quoteIdMask, $maskedQuoteId, 'masked_id'); + + $cart = $this->cartRepository->get($quoteIdMask->getQuoteId()); + + return (int) $cart->getId(); + } +} diff --git a/app/code/Magento/Quote/Model/MaskedQuoteIdToQuoteIdInterface.php b/app/code/Magento/Quote/Model/MaskedQuoteIdToQuoteIdInterface.php new file mode 100644 index 000000000000..152d575e059c --- /dev/null +++ b/app/code/Magento/Quote/Model/MaskedQuoteIdToQuoteIdInterface.php @@ -0,0 +1,24 @@ +quoteIdMaskFactory = $quoteIdMaskFactory; + $this->cartRepository = $cartRepository; + } + + /** + * {@inheritDoc} + */ + public function execute(int $quoteId): string + { + /* Check the quote exists to avoid database constraint issues */ + $this->cartRepository->get($quoteId); + + $quoteIdMask = $this->quoteIdMaskFactory->create(); + $quoteIdMask->setQuoteId($quoteId)->save(); + + return $quoteIdMask->getMaskedId(); + } +} diff --git a/app/code/Magento/Quote/Model/QuoteIdToMaskedQuoteIdInterface.php b/app/code/Magento/Quote/Model/QuoteIdToMaskedQuoteIdInterface.php new file mode 100644 index 000000000000..4d2a8ce877d8 --- /dev/null +++ b/app/code/Magento/Quote/Model/QuoteIdToMaskedQuoteIdInterface.php @@ -0,0 +1,24 @@ + + + diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart/CreateEmptyCart.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart/CreateEmptyCart.php index 1b6e4d1bebde..e91ed958d0c4 100644 --- a/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart/CreateEmptyCart.php +++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart/CreateEmptyCart.php @@ -15,8 +15,7 @@ use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; use Magento\Quote\Api\CartManagementInterface; use Magento\Quote\Api\GuestCartManagementInterface; -use Magento\Quote\Model\QuoteIdMask; -use Magento\Quote\Model\QuoteIdMaskFactory; +use Magento\Quote\Model\QuoteIdToMaskedQuoteIdInterface; /** * {@inheritdoc} @@ -39,9 +38,9 @@ class CreateEmptyCart implements ResolverInterface private $valueFactory; /** - * @var QuoteIdMaskFactory + * @var QuoteIdToMaskedQuoteIdInterface */ - private $quoteIdMaskFactory; + private $quoteIdToMaskedId; /** * @var UserContextInterface @@ -53,20 +52,20 @@ class CreateEmptyCart implements ResolverInterface * @param GuestCartManagementInterface $guestCartManagement * @param ValueFactory $valueFactory * @param UserContextInterface $userContext - * @param QuoteIdMaskFactory $quoteIdMaskFactory + * @param QuoteIdToMaskedQuoteIdInterface $quoteIdToMaskedId */ public function __construct( CartManagementInterface $cartManagement, GuestCartManagementInterface $guestCartManagement, ValueFactory $valueFactory, UserContextInterface $userContext, - QuoteIdMaskFactory $quoteIdMaskFactory + QuoteIdToMaskedQuoteIdInterface $quoteIdToMaskedId ) { $this->cartManagement = $cartManagement; $this->guestCartManagement = $guestCartManagement; $this->valueFactory = $valueFactory; $this->userContext = $userContext; - $this->quoteIdMaskFactory = $quoteIdMaskFactory; + $this->quoteIdToMaskedId = $quoteIdToMaskedId; } /** @@ -77,17 +76,14 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value $customerId = $this->userContext->getUserId(); if ($customerId) { - $cartId = $this->cartManagement->createEmptyCartForCustomer($customerId); - /** @var QuoteIdMask $quoteIdMask */ - $quoteIdMask = $this->quoteIdMaskFactory->create(); - $quoteIdMask->setQuoteId($cartId)->save(); - $cartId = $quoteIdMask->getMaskedId(); + $quoteId = $this->cartManagement->createEmptyCartForCustomer($customerId); + $maskedQuoteId = $this->quoteIdToMaskedId->execute($quoteId); } else { - $cartId = $this->guestCartManagement->createEmptyCart(); + $maskedQuoteId = $this->guestCartManagement->createEmptyCart(); } - $result = function () use ($cartId) { - return $cartId; + $result = function () use ($maskedQuoteId) { + return $maskedQuoteId; }; return $this->valueFactory->create($result); diff --git a/dev/tests/integration/testsuite/Magento/Quote/Model/MaskedQUoteIdToQuoteIdTest.php b/dev/tests/integration/testsuite/Magento/Quote/Model/MaskedQUoteIdToQuoteIdTest.php new file mode 100644 index 000000000000..dd2693f78651 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Quote/Model/MaskedQUoteIdToQuoteIdTest.php @@ -0,0 +1,46 @@ +maskedQuoteIdToQuoteId = $objectManager->create(MaskedQuoteIdToQuoteIdInterface::class); + $this->guestCartManagement = $objectManager->create(GuestCartManagementInterface::class); + } + + public function testMaskedIdToQuoteId() + { + $maskedQuoteId = $this->guestCartManagement->createEmptyCart(); + $quoteId = $this->maskedQuoteIdToQuoteId->execute($maskedQuoteId); + + self::assertGreaterThan(0, $quoteId); + } + + public function testMaskedQuoteIdToQuoteIdForNonExistentQuote() + { + self::expectException('Magento\Framework\Exception\NoSuchEntityException'); + + $this->maskedQuoteIdToQuoteId->execute('test'); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Quote/Model/QuoteIdToMaskedQuoteIdTest.php b/dev/tests/integration/testsuite/Magento/Quote/Model/QuoteIdToMaskedQuoteIdTest.php new file mode 100644 index 000000000000..10962d2c1326 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Quote/Model/QuoteIdToMaskedQuoteIdTest.php @@ -0,0 +1,56 @@ +quoteIdToMaskedQuoteId = $objectManager->create(QuoteIdToMaskedQuoteIdInterface::class); + $this->quoteFactory = $objectManager->create(QuoteFactory::class); + $this->quoteResource = $objectManager->create(QuoteResource::class); + } + + /** + * @magentoDataFixture Magento/Sales/_files/quote.php + */ + public function testMaskedQuoteId() + { + $quote = $this->quoteFactory->create(); + $this->quoteResource->load($quote, 'test01', 'reserved_order_id'); + $maskedQuoteId = $this->quoteIdToMaskedQuoteId->execute((int) $quote->getId()); + + self::assertNotEmpty($maskedQuoteId); + } + + public function testMaskedQuoteIdWithNonExistentQuoteId() + { + self::expectException('Magento\Framework\Exception\NoSuchEntityException'); + + $this->quoteIdToMaskedQuoteId->execute(0); + } +} From 439df246286a8e0b1bd96feb13f79cc053c0b9bf Mon Sep 17 00:00:00 2001 From: Valeriy Nayda Date: Mon, 3 Sep 2018 11:57:10 +0300 Subject: [PATCH 13/13] GraphQL-118: [Mutations] Cart Operations > Create Empty Cart -- Slight fixes --- .../Magento/Quote/Model/MaskedQuoteIdToQuoteId.php | 4 ++-- .../Magento/Quote/Model/QuoteIdToMaskedQuoteId.php | 2 +- .../Model/Resolver/Cart/CreateEmptyCart.php | 12 +++++------- app/code/Magento/QuoteGraphQl/etc/module.xml | 6 +----- 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/app/code/Magento/Quote/Model/MaskedQuoteIdToQuoteId.php b/app/code/Magento/Quote/Model/MaskedQuoteIdToQuoteId.php index 1eefef23c7ad..f30d98342beb 100644 --- a/app/code/Magento/Quote/Model/MaskedQuoteIdToQuoteId.php +++ b/app/code/Magento/Quote/Model/MaskedQuoteIdToQuoteId.php @@ -43,7 +43,7 @@ public function __construct( } /** - * {@inheritDoc} + * @inheritDoc */ public function execute(string $maskedQuoteId): int { @@ -52,6 +52,6 @@ public function execute(string $maskedQuoteId): int $cart = $this->cartRepository->get($quoteIdMask->getQuoteId()); - return (int) $cart->getId(); + return (int)$cart->getId(); } } diff --git a/app/code/Magento/Quote/Model/QuoteIdToMaskedQuoteId.php b/app/code/Magento/Quote/Model/QuoteIdToMaskedQuoteId.php index 65d2caef120e..5ddadfc22f57 100644 --- a/app/code/Magento/Quote/Model/QuoteIdToMaskedQuoteId.php +++ b/app/code/Magento/Quote/Model/QuoteIdToMaskedQuoteId.php @@ -34,7 +34,7 @@ public function __construct( } /** - * {@inheritDoc} + * @inheritDoc */ public function execute(int $quoteId): string { diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart/CreateEmptyCart.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart/CreateEmptyCart.php index e91ed958d0c4..18c70ccceca0 100644 --- a/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart/CreateEmptyCart.php +++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/Cart/CreateEmptyCart.php @@ -18,7 +18,7 @@ use Magento\Quote\Model\QuoteIdToMaskedQuoteIdInterface; /** - * {@inheritdoc} + * @inheritdoc */ class CreateEmptyCart implements ResolverInterface { @@ -69,23 +69,21 @@ public function __construct( } /** - * {@inheritDoc} + * @inheritDoc */ public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null) : Value { $customerId = $this->userContext->getUserId(); - if ($customerId) { + if (null !== $customerId) { $quoteId = $this->cartManagement->createEmptyCartForCustomer($customerId); $maskedQuoteId = $this->quoteIdToMaskedId->execute($quoteId); } else { $maskedQuoteId = $this->guestCartManagement->createEmptyCart(); } - $result = function () use ($maskedQuoteId) { + return $this->valueFactory->create(function () use ($maskedQuoteId) { return $maskedQuoteId; - }; - - return $this->valueFactory->create($result); + }); } } diff --git a/app/code/Magento/QuoteGraphQl/etc/module.xml b/app/code/Magento/QuoteGraphQl/etc/module.xml index 9a0b727b1037..9f29b124abbb 100644 --- a/app/code/Magento/QuoteGraphQl/etc/module.xml +++ b/app/code/Magento/QuoteGraphQl/etc/module.xml @@ -6,9 +6,5 @@ */ --> - - - - - +