5
5
*/
6
6
namespace Magento \Quote \Model ;
7
7
8
+ use Magento \Framework \Api \ExtensionAttribute \JoinProcessorInterface ;
9
+ use Magento \Framework \Api \Search \FilterGroup ;
10
+ use Magento \Framework \Api \SearchCriteria \CollectionProcessor ;
8
11
use Magento \Framework \Api \SearchCriteria \CollectionProcessorInterface ;
12
+ use Magento \Framework \Api \SearchCriteriaInterface ;
9
13
use Magento \Framework \App \ObjectManager ;
10
- use Magento \Framework \Api \ SortOrder ;
14
+ use Magento \Framework \Exception \ InputException ;
11
15
use Magento \Framework \Exception \NoSuchEntityException ;
16
+ use Magento \Quote \Api \CartRepositoryInterface ;
12
17
use Magento \Quote \Api \Data \CartInterface ;
13
- use Magento \Quote \Model \Quote ;
14
- use Magento \Store \Model \StoreManagerInterface ;
15
- use Magento \Framework \Api \Search \FilterGroup ;
16
- use Magento \Quote \Model \ResourceModel \Quote \Collection as QuoteCollection ;
17
- use Magento \Quote \Model \ResourceModel \Quote \CollectionFactory as QuoteCollectionFactory ;
18
- use Magento \Framework \Exception \InputException ;
19
- use Magento \Framework \Api \ExtensionAttribute \JoinProcessorInterface ;
18
+ use Magento \Quote \Api \Data \CartInterfaceFactory ;
19
+ use Magento \Quote \Api \Data \CartSearchResultsInterfaceFactory ;
20
20
use Magento \Quote \Model \QuoteRepository \SaveHandler ;
21
21
use Magento \Quote \Model \QuoteRepository \LoadHandler ;
22
+ use Magento \Quote \Model \ResourceModel \Quote \Collection as QuoteCollection ;
23
+ use Magento \Quote \Model \ResourceModel \Quote \CollectionFactory as QuoteCollectionFactory ;
24
+ use Magento \Store \Model \StoreManagerInterface ;
22
25
23
26
/**
24
27
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
25
28
*/
26
- class QuoteRepository implements \ Magento \ Quote \ Api \ CartRepositoryInterface
29
+ class QuoteRepository implements CartRepositoryInterface
27
30
{
28
31
/**
29
32
* @var Quote[]
@@ -37,6 +40,7 @@ class QuoteRepository implements \Magento\Quote\Api\CartRepositoryInterface
37
40
38
41
/**
39
42
* @var QuoteFactory
43
+ * @deprecated
40
44
*/
41
45
protected $ quoteFactory ;
42
46
@@ -46,13 +50,13 @@ class QuoteRepository implements \Magento\Quote\Api\CartRepositoryInterface
46
50
protected $ storeManager ;
47
51
48
52
/**
49
- * @var \Magento\Quote\Model\ResourceModel\Quote\Collection
53
+ * @var QuoteCollection
50
54
* @deprecated 100.2.0
51
55
*/
52
56
protected $ quoteCollection ;
53
57
54
58
/**
55
- * @var \Magento\Quote\Api\Data\ CartSearchResultsInterfaceFactory
59
+ * @var CartSearchResultsInterfaceFactory
56
60
*/
57
61
protected $ searchResultsDataFactory ;
58
62
@@ -77,39 +81,47 @@ class QuoteRepository implements \Magento\Quote\Api\CartRepositoryInterface
77
81
private $ collectionProcessor ;
78
82
79
83
/**
80
- * @var \Magento\Quote\Model\ResourceModel\Quote\CollectionFactory
84
+ * @var QuoteCollectionFactory
81
85
*/
82
86
private $ quoteCollectionFactory ;
83
87
88
+ /**
89
+ * @var CartInterfaceFactory
90
+ */
91
+ private $ cartFactory ;
92
+
84
93
/**
85
94
* Constructor
86
95
*
87
96
* @param QuoteFactory $quoteFactory
88
97
* @param StoreManagerInterface $storeManager
89
- * @param \Magento\Quote\Model\ResourceModel\Quote\Collection $quoteCollection
90
- * @param \Magento\Quote\Api\Data\ CartSearchResultsInterfaceFactory $searchResultsDataFactory
98
+ * @param QuoteCollection $quoteCollection
99
+ * @param CartSearchResultsInterfaceFactory $searchResultsDataFactory
91
100
* @param JoinProcessorInterface $extensionAttributesJoinProcessor
92
101
* @param CollectionProcessorInterface|null $collectionProcessor
93
- * @param \Magento\Quote\Model\ResourceModel\Quote\CollectionFactory|null $quoteCollectionFactory
102
+ * @param QuoteCollectionFactory|null $quoteCollectionFactory
103
+ * @param CartInterfaceFactory|null $cartFactory
94
104
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
95
105
*/
96
106
public function __construct (
97
107
QuoteFactory $ quoteFactory ,
98
108
StoreManagerInterface $ storeManager ,
99
- \ Magento \ Quote \ Model \ ResourceModel \ Quote \ Collection $ quoteCollection ,
100
- \ Magento \ Quote \ Api \ Data \ CartSearchResultsInterfaceFactory $ searchResultsDataFactory ,
109
+ QuoteCollection $ quoteCollection ,
110
+ CartSearchResultsInterfaceFactory $ searchResultsDataFactory ,
101
111
JoinProcessorInterface $ extensionAttributesJoinProcessor ,
102
112
CollectionProcessorInterface $ collectionProcessor = null ,
103
- \Magento \Quote \Model \ResourceModel \Quote \CollectionFactory $ quoteCollectionFactory = null
113
+ QuoteCollectionFactory $ quoteCollectionFactory = null ,
114
+ CartInterfaceFactory $ cartFactory = null
104
115
) {
105
116
$ this ->quoteFactory = $ quoteFactory ;
106
117
$ this ->storeManager = $ storeManager ;
107
118
$ this ->searchResultsDataFactory = $ searchResultsDataFactory ;
108
119
$ this ->extensionAttributesJoinProcessor = $ extensionAttributesJoinProcessor ;
109
- $ this ->collectionProcessor = $ collectionProcessor ?: \Magento \Framework \App \ObjectManager::getInstance ()
110
- ->get (\Magento \Framework \Api \SearchCriteria \CollectionProcessor::class);
111
- $ this ->quoteCollectionFactory = $ quoteCollectionFactory ?: \Magento \Framework \App \ObjectManager::getInstance ()
112
- ->get (\Magento \Quote \Model \ResourceModel \Quote \CollectionFactory::class);
120
+ $ this ->collectionProcessor = $ collectionProcessor ?: ObjectManager::getInstance ()
121
+ ->get (CollectionProcessor::class);
122
+ $ this ->quoteCollectionFactory = $ quoteCollectionFactory ?: ObjectManager::getInstance ()
123
+ ->get (QuoteCollectionFactory::class);
124
+ $ this ->cartFactory = $ cartFactory ?: ObjectManager::getInstance ()->get (CartInterfaceFactory::class);
113
125
}
114
126
115
127
/**
@@ -166,7 +178,7 @@ public function getActiveForCustomer($customerId, array $sharedStoreIds = [])
166
178
/**
167
179
* {@inheritdoc}
168
180
*/
169
- public function save (\ Magento \ Quote \ Api \ Data \ CartInterface $ quote )
181
+ public function save (CartInterface $ quote )
170
182
{
171
183
if ($ quote ->getId ()) {
172
184
$ currentQuote = $ this ->get ($ quote ->getId (), [$ quote ->getStoreId ()]);
@@ -186,7 +198,7 @@ public function save(\Magento\Quote\Api\Data\CartInterface $quote)
186
198
/**
187
199
* {@inheritdoc}
188
200
*/
189
- public function delete (\ Magento \ Quote \ Api \ Data \ CartInterface $ quote )
201
+ public function delete (CartInterface $ quote )
190
202
{
191
203
$ quoteId = $ quote ->getId ();
192
204
$ customerId = $ quote ->getCustomerId ();
@@ -203,13 +215,13 @@ public function delete(\Magento\Quote\Api\Data\CartInterface $quote)
203
215
* @param int $identifier
204
216
* @param int[] $sharedStoreIds
205
217
* @throws NoSuchEntityException
206
- * @return Quote
218
+ * @return CartInterface
207
219
*/
208
220
protected function loadQuote ($ loadMethod , $ loadField , $ identifier , array $ sharedStoreIds = [])
209
221
{
210
- /** @var Quote $quote */
211
- $ quote = $ this ->quoteFactory ->create ();
212
- if ($ sharedStoreIds ) {
222
+ /** @var CartInterface $quote */
223
+ $ quote = $ this ->cartFactory ->create ();
224
+ if ($ sharedStoreIds && method_exists ( $ quote , ' setSharedStoreIds ' ) ) {
213
225
$ quote ->setSharedStoreIds ($ sharedStoreIds );
214
226
}
215
227
$ quote ->setStoreId ($ this ->storeManager ->getStore ()->getId ())->$ loadMethod ($ identifier );
@@ -222,7 +234,7 @@ protected function loadQuote($loadMethod, $loadField, $identifier, array $shared
222
234
/**
223
235
* {@inheritdoc}
224
236
*/
225
- public function getList (\ Magento \ Framework \ Api \ SearchCriteriaInterface $ searchCriteria )
237
+ public function getList (SearchCriteriaInterface $ searchCriteria )
226
238
{
227
239
$ this ->quoteCollection = $ this ->quoteCollectionFactory ->create ();
228
240
/** @var \Magento\Quote\Api\Data\CartSearchResultsInterface $searchData */
0 commit comments