Skip to content

Commit

Permalink
GraphQL-118: [Mutations] Cart Operations > Create Empty Cart
Browse files Browse the repository at this point in the history
-- Slight fixes
  • Loading branch information
Valeriy Nayda committed Sep 3, 2018
1 parent 3176de0 commit 439df24
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
4 changes: 2 additions & 2 deletions app/code/Magento/Quote/Model/MaskedQuoteIdToQuoteId.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct(
}

/**
* {@inheritDoc}
* @inheritDoc
*/
public function execute(string $maskedQuoteId): int
{
Expand All @@ -52,6 +52,6 @@ public function execute(string $maskedQuoteId): int

$cart = $this->cartRepository->get($quoteIdMask->getQuoteId());

return (int) $cart->getId();
return (int)$cart->getId();
}
}
2 changes: 1 addition & 1 deletion app/code/Magento/Quote/Model/QuoteIdToMaskedQuoteId.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct(
}

/**
* {@inheritDoc}
* @inheritDoc
*/
public function execute(int $quoteId): string
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Magento\Quote\Model\QuoteIdToMaskedQuoteIdInterface;

/**
* {@inheritdoc}
* @inheritdoc
*/
class CreateEmptyCart implements ResolverInterface
{
Expand Down Expand Up @@ -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);
});
}
}
6 changes: 1 addition & 5 deletions app/code/Magento/QuoteGraphQl/etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,5 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Magento_QuoteGraphQl">
<sequence>
<module name="Magento_GraphQl"/>
</sequence>
</module>
<module name="Magento_QuoteGraphQl"/>
</config>

0 comments on commit 439df24

Please sign in to comment.