3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+
6
7
namespace Magento \Quote \Model ;
7
8
9
+ use Magento \Framework \Api \ExtensionAttribute \JoinProcessorInterface ;
10
+ use Magento \Framework \Api \Search \FilterGroup ;
11
+ use Magento \Framework \Api \SearchCriteria \CollectionProcessor ;
8
12
use Magento \Framework \Api \SearchCriteria \CollectionProcessorInterface ;
13
+ use Magento \Framework \Api \SearchCriteriaInterface ;
9
14
use Magento \Framework \App \ObjectManager ;
10
- use Magento \Framework \Api \ SortOrder ;
15
+ use Magento \Framework \Exception \ InputException ;
11
16
use Magento \Framework \Exception \NoSuchEntityException ;
17
+ use Magento \Quote \Api \CartRepositoryInterface ;
12
18
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 ;
19
+ use Magento \Quote \Api \Data \CartInterfaceFactory ;
20
+ use Magento \Quote \Api \Data \CartSearchResultsInterfaceFactory ;
20
21
use Magento \Quote \Model \QuoteRepository \SaveHandler ;
21
22
use Magento \Quote \Model \QuoteRepository \LoadHandler ;
23
+ use Magento \Quote \Model \ResourceModel \Quote \Collection as QuoteCollection ;
24
+ use Magento \Quote \Model \ResourceModel \Quote \CollectionFactory as QuoteCollectionFactory ;
25
+ use Magento \Store \Model \StoreManagerInterface ;
22
26
23
27
/**
28
+ * Quote repository.
29
+ *
24
30
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
25
31
*/
26
- class QuoteRepository implements \ Magento \ Quote \ Api \ CartRepositoryInterface
32
+ class QuoteRepository implements CartRepositoryInterface
27
33
{
28
34
/**
29
35
* @var Quote[]
@@ -37,6 +43,7 @@ class QuoteRepository implements \Magento\Quote\Api\CartRepositoryInterface
37
43
38
44
/**
39
45
* @var QuoteFactory
46
+ * @deprecated
40
47
*/
41
48
protected $ quoteFactory ;
42
49
@@ -46,13 +53,13 @@ class QuoteRepository implements \Magento\Quote\Api\CartRepositoryInterface
46
53
protected $ storeManager ;
47
54
48
55
/**
49
- * @var \Magento\Quote\Model\ResourceModel\Quote\Collection
56
+ * @var QuoteCollection
50
57
* @deprecated 100.2.0
51
58
*/
52
59
protected $ quoteCollection ;
53
60
54
61
/**
55
- * @var \Magento\Quote\Api\Data\ CartSearchResultsInterfaceFactory
62
+ * @var CartSearchResultsInterfaceFactory
56
63
*/
57
64
protected $ searchResultsDataFactory ;
58
65
@@ -77,43 +84,51 @@ class QuoteRepository implements \Magento\Quote\Api\CartRepositoryInterface
77
84
private $ collectionProcessor ;
78
85
79
86
/**
80
- * @var \Magento\Quote\Model\ResourceModel\Quote\CollectionFactory
87
+ * @var QuoteCollectionFactory
81
88
*/
82
89
private $ quoteCollectionFactory ;
83
90
91
+ /**
92
+ * @var CartInterfaceFactory
93
+ */
94
+ private $ cartFactory ;
95
+
84
96
/**
85
97
* Constructor
86
98
*
87
99
* @param QuoteFactory $quoteFactory
88
100
* @param StoreManagerInterface $storeManager
89
- * @param \Magento\Quote\Model\ResourceModel\Quote\Collection $quoteCollection
90
- * @param \Magento\Quote\Api\Data\ CartSearchResultsInterfaceFactory $searchResultsDataFactory
101
+ * @param QuoteCollection $quoteCollection
102
+ * @param CartSearchResultsInterfaceFactory $searchResultsDataFactory
91
103
* @param JoinProcessorInterface $extensionAttributesJoinProcessor
92
104
* @param CollectionProcessorInterface|null $collectionProcessor
93
- * @param \Magento\Quote\Model\ResourceModel\Quote\CollectionFactory|null $quoteCollectionFactory
105
+ * @param QuoteCollectionFactory|null $quoteCollectionFactory
106
+ * @param CartInterfaceFactory|null $cartFactory
94
107
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
95
108
*/
96
109
public function __construct (
97
110
QuoteFactory $ quoteFactory ,
98
111
StoreManagerInterface $ storeManager ,
99
- \ Magento \ Quote \ Model \ ResourceModel \ Quote \ Collection $ quoteCollection ,
100
- \ Magento \ Quote \ Api \ Data \ CartSearchResultsInterfaceFactory $ searchResultsDataFactory ,
112
+ QuoteCollection $ quoteCollection ,
113
+ CartSearchResultsInterfaceFactory $ searchResultsDataFactory ,
101
114
JoinProcessorInterface $ extensionAttributesJoinProcessor ,
102
115
CollectionProcessorInterface $ collectionProcessor = null ,
103
- \Magento \Quote \Model \ResourceModel \Quote \CollectionFactory $ quoteCollectionFactory = null
116
+ QuoteCollectionFactory $ quoteCollectionFactory = null ,
117
+ CartInterfaceFactory $ cartFactory = null
104
118
) {
105
119
$ this ->quoteFactory = $ quoteFactory ;
106
120
$ this ->storeManager = $ storeManager ;
107
121
$ this ->searchResultsDataFactory = $ searchResultsDataFactory ;
108
122
$ 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);
123
+ $ this ->collectionProcessor = $ collectionProcessor ?: ObjectManager::getInstance ()
124
+ ->get (CollectionProcessor::class);
125
+ $ this ->quoteCollectionFactory = $ quoteCollectionFactory ?: ObjectManager::getInstance ()
126
+ ->get (QuoteCollectionFactory::class);
127
+ $ this ->cartFactory = $ cartFactory ?: ObjectManager::getInstance ()->get (CartInterfaceFactory::class);
113
128
}
114
129
115
130
/**
116
- * { @inheritdoc}
131
+ * @inheritdoc
117
132
*/
118
133
public function get ($ cartId , array $ sharedStoreIds = [])
119
134
{
@@ -126,7 +141,7 @@ public function get($cartId, array $sharedStoreIds = [])
126
141
}
127
142
128
143
/**
129
- * { @inheritdoc}
144
+ * @inheritdoc
130
145
*/
131
146
public function getForCustomer ($ customerId , array $ sharedStoreIds = [])
132
147
{
@@ -140,7 +155,7 @@ public function getForCustomer($customerId, array $sharedStoreIds = [])
140
155
}
141
156
142
157
/**
143
- * { @inheritdoc}
158
+ * @inheritdoc
144
159
*/
145
160
public function getActive ($ cartId , array $ sharedStoreIds = [])
146
161
{
@@ -152,7 +167,7 @@ public function getActive($cartId, array $sharedStoreIds = [])
152
167
}
153
168
154
169
/**
155
- * { @inheritdoc}
170
+ * @inheritdoc
156
171
*/
157
172
public function getActiveForCustomer ($ customerId , array $ sharedStoreIds = [])
158
173
{
@@ -164,9 +179,9 @@ public function getActiveForCustomer($customerId, array $sharedStoreIds = [])
164
179
}
165
180
166
181
/**
167
- * { @inheritdoc}
182
+ * @inheritdoc
168
183
*/
169
- public function save (\ Magento \ Quote \ Api \ Data \ CartInterface $ quote )
184
+ public function save (CartInterface $ quote )
170
185
{
171
186
if ($ quote ->getId ()) {
172
187
$ currentQuote = $ this ->get ($ quote ->getId (), [$ quote ->getStoreId ()]);
@@ -184,9 +199,9 @@ public function save(\Magento\Quote\Api\Data\CartInterface $quote)
184
199
}
185
200
186
201
/**
187
- * { @inheritdoc}
202
+ * @inheritdoc
188
203
*/
189
- public function delete (\ Magento \ Quote \ Api \ Data \ CartInterface $ quote )
204
+ public function delete (CartInterface $ quote )
190
205
{
191
206
$ quoteId = $ quote ->getId ();
192
207
$ customerId = $ quote ->getCustomerId ();
@@ -203,13 +218,13 @@ public function delete(\Magento\Quote\Api\Data\CartInterface $quote)
203
218
* @param int $identifier
204
219
* @param int[] $sharedStoreIds
205
220
* @throws NoSuchEntityException
206
- * @return Quote
221
+ * @return CartInterface
207
222
*/
208
223
protected function loadQuote ($ loadMethod , $ loadField , $ identifier , array $ sharedStoreIds = [])
209
224
{
210
- /** @var Quote $quote */
211
- $ quote = $ this ->quoteFactory ->create ();
212
- if ($ sharedStoreIds ) {
225
+ /** @var CartInterface $quote */
226
+ $ quote = $ this ->cartFactory ->create ();
227
+ if ($ sharedStoreIds && method_exists ( $ quote , ' setSharedStoreIds ' ) ) {
213
228
$ quote ->setSharedStoreIds ($ sharedStoreIds );
214
229
}
215
230
$ quote ->setStoreId ($ this ->storeManager ->getStore ()->getId ())->$ loadMethod ($ identifier );
@@ -220,9 +235,9 @@ protected function loadQuote($loadMethod, $loadField, $identifier, array $shared
220
235
}
221
236
222
237
/**
223
- * { @inheritdoc}
238
+ * @inheritdoc
224
239
*/
225
- public function getList (\ Magento \ Framework \ Api \ SearchCriteriaInterface $ searchCriteria )
240
+ public function getList (SearchCriteriaInterface $ searchCriteria )
226
241
{
227
242
$ this ->quoteCollection = $ this ->quoteCollectionFactory ->create ();
228
243
/** @var \Magento\Quote\Api\Data\CartSearchResultsInterface $searchData */
@@ -265,6 +280,7 @@ protected function addFilterGroupToCollection(FilterGroup $filterGroup, QuoteCol
265
280
266
281
/**
267
282
* Get new SaveHandler dependency for application code.
283
+ *
268
284
* @return SaveHandler
269
285
* @deprecated 100.1.0
270
286
*/
@@ -277,6 +293,8 @@ private function getSaveHandler()
277
293
}
278
294
279
295
/**
296
+ * Get load handler instance.
297
+ *
280
298
* @return LoadHandler
281
299
* @deprecated 100.1.0
282
300
*/
0 commit comments