7
7
8
8
namespace Magento \QuoteGraphQl \Model \Resolver \Cart ;
9
9
10
+ use Magento \Authorization \Model \UserContextInterface ;
11
+ use Magento \Framework \GraphQl \Config \Element \Field ;
10
12
use Magento \Framework \GraphQl \Query \Resolver \Value ;
11
13
use Magento \Framework \GraphQl \Query \Resolver \ValueFactory ;
12
- use Magento \Framework \GraphQl \Config \Element \Field ;
13
14
use Magento \Framework \GraphQl \Query \ResolverInterface ;
14
15
use Magento \Framework \GraphQl \Schema \Type \ResolveInfo ;
15
- use Magento \Quote \Api \GuestCartManagementInterface ;
16
16
use Magento \Quote \Api \CartManagementInterface ;
17
- use Magento \Authorization \Model \UserContextInterface ;
17
+ use Magento \Quote \Api \GuestCartManagementInterface ;
18
+ use Magento \Quote \Model \QuoteIdMask ;
19
+ use Magento \Quote \Model \QuoteIdMaskFactory ;
18
20
19
21
/**
20
22
* {@inheritdoc}
@@ -36,6 +38,11 @@ class CreateEmptyCart implements ResolverInterface
36
38
*/
37
39
private $ valueFactory ;
38
40
41
+ /**
42
+ * @var QuoteIdMaskFactory
43
+ */
44
+ private $ quoteIdMaskFactory ;
45
+
39
46
/**
40
47
* @var UserContextInterface
41
48
*/
@@ -46,17 +53,20 @@ class CreateEmptyCart implements ResolverInterface
46
53
* @param GuestCartManagementInterface $guestCartManagement
47
54
* @param ValueFactory $valueFactory
48
55
* @param UserContextInterface $userContext
56
+ * @param QuoteIdMaskFactory $quoteIdMaskFactory
49
57
*/
50
58
public function __construct (
51
59
CartManagementInterface $ cartManagement ,
52
60
GuestCartManagementInterface $ guestCartManagement ,
53
61
ValueFactory $ valueFactory ,
54
- UserContextInterface $ userContext
62
+ UserContextInterface $ userContext ,
63
+ QuoteIdMaskFactory $ quoteIdMaskFactory
55
64
) {
56
65
$ this ->cartManagement = $ cartManagement ;
57
66
$ this ->guestCartManagement = $ guestCartManagement ;
58
67
$ this ->valueFactory = $ valueFactory ;
59
68
$ this ->userContext = $ userContext ;
69
+ $ this ->quoteIdMaskFactory = $ quoteIdMaskFactory ;
60
70
}
61
71
62
72
/**
@@ -68,6 +78,10 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
68
78
69
79
if ($ customerId ) {
70
80
$ cartId = $ this ->cartManagement ->createEmptyCartForCustomer ($ customerId );
81
+ /** @var QuoteIdMask $quoteIdMask */
82
+ $ quoteIdMask = $ this ->quoteIdMaskFactory ->create ();
83
+ $ quoteIdMask ->setQuoteId ($ cartId )->save ();
84
+ $ cartId = $ quoteIdMask ->getMaskedId ();
71
85
} else {
72
86
$ cartId = $ this ->guestCartManagement ->createEmptyCart ();
73
87
}
0 commit comments