1212use Magento \Sales \Api \OrderRepositoryInterface ;
1313use Magento \Sales \Model \Order \Invoice ;
1414use Magento \Sales \Model \ValidatorInterface ;
15+ use Magento \Framework \App \Config \ScopeConfigInterface ;
1516use Magento \Framework \App \ObjectManager ;
1617
1718class CanRefund implements ValidatorInterface
@@ -27,23 +28,25 @@ class CanRefund implements ValidatorInterface
2728 private $ orderRepository ;
2829
2930 /**
30- * @var ObjectManager
31+ * @var ScopeConfigInterface
3132 */
32- private $ objectManager ;
33+ private $ scopeConfig ;
3334
3435 /**
3536 * CanRefund constructor.
3637 *
3738 * @param OrderPaymentRepositoryInterface $paymentRepository
3839 * @param OrderRepositoryInterface $orderRepository
40+ * @param ScopeConfigInterface|null $scopeConfig
3941 */
4042 public function __construct (
4143 OrderPaymentRepositoryInterface $ paymentRepository ,
42- OrderRepositoryInterface $ orderRepository
44+ OrderRepositoryInterface $ orderRepository ,
45+ ?ScopeConfigInterface $ scopeConfig = null
4346 ) {
44- $ this ->objectManager = ObjectManager::getInstance ();
4547 $ this ->paymentRepository = $ paymentRepository ;
4648 $ this ->orderRepository = $ orderRepository ;
49+ $ this ->scopeConfig = $ scopeConfig ?? ObjectManager::getInstance ()->get (ScopeConfigInterface::class);
4750 }
4851
4952 /**
@@ -89,7 +92,7 @@ private function isPaymentAllowRefund(InvoiceInterface $invoice)
8992 */
9093 private function isGrandTotalEnoughToRefund (InvoiceInterface $ entity )
9194 {
92- $ isAllowedZeroGrandTotal = $ this ->objectManager -> get (ScopeConfigInterface::class) ->getValue (
95+ $ isAllowedZeroGrandTotal = $ this ->scopeConfig ->getValue (
9396 'sales/zerograndtotal_creditmemo/allow_zero_grandtotal ' ,
9497 \Magento \Store \Model \ScopeInterface::SCOPE_STORE
9598 );
0 commit comments