Skip to content

Commit a127c71

Browse files
committed
MCP-409: Add cart repository to payment information management construct parameters
1 parent 21eefc7 commit a127c71

File tree

1 file changed

+8
-20
lines changed

1 file changed

+8
-20
lines changed

app/code/Magento/Checkout/Model/PaymentInformationManagement.php

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Checkout\Api\PaymentSavingRateLimiterInterface;
1212
use Magento\Framework\App\ObjectManager;
1313
use Magento\Framework\Exception\CouldNotSaveException;
14+
use Magento\Quote\Api\CartRepositoryInterface;
1415

1516
/**
1617
* Payment information management service.
@@ -51,7 +52,7 @@ class PaymentInformationManagement implements \Magento\Checkout\Api\PaymentInfor
5152
private $logger;
5253

5354
/**
54-
* @var \Magento\Quote\Api\CartRepositoryInterface
55+
* @var CartRepositoryInterface
5556
*/
5657
private $cartRepository;
5758

@@ -78,6 +79,7 @@ class PaymentInformationManagement implements \Magento\Checkout\Api\PaymentInfor
7879
* @param \Magento\Quote\Api\CartTotalRepositoryInterface $cartTotalsRepository
7980
* @param PaymentProcessingRateLimiterInterface|null $paymentRateLimiter
8081
* @param PaymentSavingRateLimiterInterface|null $saveRateLimiter
82+
* @param CartRepositoryInterface|null $cartRepository
8183
* @codeCoverageIgnore
8284
*/
8385
public function __construct(
@@ -87,7 +89,8 @@ public function __construct(
8789
\Magento\Checkout\Model\PaymentDetailsFactory $paymentDetailsFactory,
8890
\Magento\Quote\Api\CartTotalRepositoryInterface $cartTotalsRepository,
8991
?PaymentProcessingRateLimiterInterface $paymentRateLimiter = null,
90-
?PaymentSavingRateLimiterInterface $saveRateLimiter = null
92+
?PaymentSavingRateLimiterInterface $saveRateLimiter = null,
93+
?CartRepositoryInterface $cartRepository = null
9194
) {
9295
$this->billingAddressManagement = $billingAddressManagement;
9396
$this->paymentMethodManagement = $paymentMethodManagement;
@@ -98,6 +101,8 @@ public function __construct(
98101
?? ObjectManager::getInstance()->get(PaymentProcessingRateLimiterInterface::class);
99102
$this->saveRateLimiter = $saveRateLimiter
100103
?? ObjectManager::getInstance()->get(PaymentSavingRateLimiterInterface::class);
104+
$this->cartRepository = $cartRepository
105+
?? ObjectManager::getInstance()->get(CartRepositoryInterface::class);
101106
}
102107

103108
/**
@@ -154,10 +159,8 @@ public function savePaymentInformation(
154159
}
155160

156161
if ($billingAddress) {
157-
/** @var \Magento\Quote\Api\CartRepositoryInterface $quoteRepository */
158-
$quoteRepository = $this->getCartRepository();
159162
/** @var \Magento\Quote\Model\Quote $quote */
160-
$quote = $quoteRepository->getActive($cartId);
163+
$quote = $this->cartRepository->getActive($cartId);
161164
$customerId = $quote->getBillingAddress()
162165
->getCustomerId();
163166
if (!$billingAddress->getCustomerId() && $customerId) {
@@ -204,19 +207,4 @@ private function getLogger()
204207
}
205208
return $this->logger;
206209
}
207-
208-
/**
209-
* Get Cart repository
210-
*
211-
* @return \Magento\Quote\Api\CartRepositoryInterface
212-
* @deprecated 100.2.0
213-
*/
214-
private function getCartRepository()
215-
{
216-
if (!$this->cartRepository) {
217-
$this->cartRepository = ObjectManager::getInstance()
218-
->get(\Magento\Quote\Api\CartRepositoryInterface::class);
219-
}
220-
return $this->cartRepository;
221-
}
222210
}

0 commit comments

Comments
 (0)