Skip to content
This repository was archived by the owner on Dec 19, 2019. It is now read-only.

Commit 3f3556d

Browse files
author
Roman Glushko
committed
#141 Refactored hydrator to data provider
1 parent 4942c6f commit 3f3556d

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

app/code/Magento/QuoteGraphQl/Model/Resolver/Cart/AddSimpleProductsToCart.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
use Magento\Quote\Model\MaskedQuoteIdToQuoteIdInterface;
2323
use Magento\Quote\Model\Quote;
2424
use Magento\QuoteGraphQl\Model\Cart\AddSimpleProductToCartProcessor;
25-
use Magento\QuoteGraphQl\Model\Resolver\DataProvider\Cart\CartHydrator;
25+
use Magento\QuoteGraphQl\Model\Resolver\DataProvider\Cart\CartItems;
2626

2727
/**
2828
* Add simple product to cart GraphQl resolver
@@ -46,9 +46,9 @@ class AddSimpleProductsToCart implements ResolverInterface
4646
private $maskedQuoteIdToQuoteId;
4747

4848
/**
49-
* @var CartHydrator
49+
* @var CartItems
5050
*/
51-
private $cartHydrator;
51+
private $cartItemsDataProvider;
5252

5353
/**
5454
* @var ArrayManager
@@ -67,7 +67,7 @@ class AddSimpleProductsToCart implements ResolverInterface
6767

6868
/**
6969
* @param AddSimpleProductToCartProcessor $addSimpleProductToCartProcessor
70-
* @param CartHydrator $cartHydrator
70+
* @param CartItems $cartItemsDataProvider
7171
* @param ArrayManager $arrayManager
7272
* @param MaskedQuoteIdToQuoteIdInterface $maskedQuoteIdToQuoteId
7373
* @param CartRepositoryInterface $cartRepository
@@ -76,7 +76,7 @@ class AddSimpleProductsToCart implements ResolverInterface
7676
*/
7777
public function __construct(
7878
AddSimpleProductToCartProcessor $addSimpleProductToCartProcessor,
79-
CartHydrator $cartHydrator,
79+
CartItems $cartItemsDataProvider,
8080
ArrayManager $arrayManager,
8181
MaskedQuoteIdToQuoteIdInterface $maskedQuoteIdToQuoteId,
8282
CartRepositoryInterface $cartRepository,
@@ -86,7 +86,7 @@ public function __construct(
8686
$this->valueFactory = $valueFactory;
8787
$this->userContext = $userContext;
8888
$this->arrayManager = $arrayManager;
89-
$this->cartHydrator = $cartHydrator;
89+
$this->cartItemsDataProvider = $cartItemsDataProvider;
9090
$this->cartRepository = $cartRepository;
9191
$this->maskedQuoteIdToQuoteId = $maskedQuoteIdToQuoteId;
9292
$this->addSimpleProductToCartProcessor = $addSimpleProductToCartProcessor;
@@ -137,7 +137,7 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
137137

138138
$result = function () use ($cart) {
139139
return [
140-
'cart' => $this->cartHydrator->hydrate($cart)
140+
'cart' => $this->cartItemsDataProvider->getData($cart)
141141
];
142142
};
143143

app/code/Magento/QuoteGraphQl/Model/Resolver/DataProvider/Cart/CartHydrator.php renamed to app/code/Magento/QuoteGraphQl/Model/Resolver/DataProvider/Cart/CartItems.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212
use Magento\Quote\Model\Quote\Item as QuoteItem;
1313

1414
/**
15-
* Cart Hydrator class
15+
* CartItems data provider class
1616
*/
17-
class CartHydrator
17+
class CartItems
1818
{
1919
/**
20-
* Hydrate cart to plain array
20+
* Provide cart items as a plain array
2121
* @param CartInterface|Quote $cart
2222
* @return array
2323
*/
24-
public function hydrate(CartInterface $cart): array
24+
public function getData(CartInterface $cart): array
2525
{
2626
$items = [];
2727

0 commit comments

Comments
 (0)