Skip to content

Commit fcd809e

Browse files
committed
Optimized usage of user context
1 parent 141c920 commit fcd809e

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
namespace Magento\QuoteGraphQl\Model\Resolver\Cart;
99

10-
use Magento\Authorization\Model\UserContextInterface;
1110
use Magento\Framework\GraphQl\Config\Element\Field;
1211
use Magento\Framework\GraphQl\Query\Resolver\Value;
1312
use Magento\Framework\GraphQl\Query\Resolver\ValueFactory;
@@ -43,29 +42,21 @@ class CreateEmptyCart implements ResolverInterface
4342
*/
4443
private $quoteIdMaskFactory;
4544

46-
/**
47-
* @var UserContextInterface
48-
*/
49-
private $userContext;
50-
5145
/**
5246
* @param CartManagementInterface $cartManagement
5347
* @param GuestCartManagementInterface $guestCartManagement
5448
* @param ValueFactory $valueFactory
55-
* @param UserContextInterface $userContext
5649
* @param QuoteIdMaskFactory $quoteIdMaskFactory
5750
*/
5851
public function __construct(
5952
CartManagementInterface $cartManagement,
6053
GuestCartManagementInterface $guestCartManagement,
6154
ValueFactory $valueFactory,
62-
UserContextInterface $userContext,
6355
QuoteIdMaskFactory $quoteIdMaskFactory
6456
) {
6557
$this->cartManagement = $cartManagement;
6658
$this->guestCartManagement = $guestCartManagement;
6759
$this->valueFactory = $valueFactory;
68-
$this->userContext = $userContext;
6960
$this->quoteIdMaskFactory = $quoteIdMaskFactory;
7061
}
7162

@@ -74,7 +65,7 @@ public function __construct(
7465
*/
7566
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null) : Value
7667
{
77-
$customerId = $this->userContext->getUserId();
68+
$customerId = $context->getUserId();
7869

7970
if ($customerId) {
8071
$cartId = $this->cartManagement->createEmptyCartForCustomer($customerId);

0 commit comments

Comments
 (0)