12
12
use Magento \Sales \Api \OrderRepositoryInterface ;
13
13
use Magento \Sales \Model \Order \Invoice ;
14
14
use Magento \Sales \Model \ValidatorInterface ;
15
+ use Magento \Framework \App \Config \ScopeConfigInterface ;
15
16
use Magento \Framework \App \ObjectManager ;
16
17
17
18
class CanRefund implements ValidatorInterface
@@ -27,23 +28,25 @@ class CanRefund implements ValidatorInterface
27
28
private $ orderRepository ;
28
29
29
30
/**
30
- * @var ObjectManager
31
+ * @var ScopeConfigInterface
31
32
*/
32
- private $ objectManager ;
33
+ private $ scopeConfig ;
33
34
34
35
/**
35
36
* CanRefund constructor.
36
37
*
37
38
* @param OrderPaymentRepositoryInterface $paymentRepository
38
39
* @param OrderRepositoryInterface $orderRepository
40
+ * @param ScopeConfigInterface|null $scopeConfig
39
41
*/
40
42
public function __construct (
41
43
OrderPaymentRepositoryInterface $ paymentRepository ,
42
- OrderRepositoryInterface $ orderRepository
44
+ OrderRepositoryInterface $ orderRepository ,
45
+ ?ScopeConfigInterface $ scopeConfig = null
43
46
) {
44
- $ this ->objectManager = ObjectManager::getInstance ();
45
47
$ this ->paymentRepository = $ paymentRepository ;
46
48
$ this ->orderRepository = $ orderRepository ;
49
+ $ this ->scopeConfig = $ scopeConfig ?? ObjectManager::getInstance ()->get (ScopeConfigInterface::class);
47
50
}
48
51
49
52
/**
@@ -89,7 +92,7 @@ private function isPaymentAllowRefund(InvoiceInterface $invoice)
89
92
*/
90
93
private function isGrandTotalEnoughToRefund (InvoiceInterface $ entity )
91
94
{
92
- $ isAllowedZeroGrandTotal = $ this ->objectManager -> get (ScopeConfigInterface::class) ->getValue (
95
+ $ isAllowedZeroGrandTotal = $ this ->scopeConfig ->getValue (
93
96
'sales/zerograndtotal_creditmemo/allow_zero_grandtotal ' ,
94
97
\Magento \Store \Model \ScopeInterface::SCOPE_STORE
95
98
);
0 commit comments