5
5
*/
6
6
namespace Magento \Payment \Ui \Component \Listing \Column \Method ;
7
7
8
+ use Magento \Payment \Api \PaymentMethodListInterface ;
9
+ use Magento \Store \Model \StoreManagerInterface ;
10
+
8
11
/**
9
12
* Class Options
10
13
*/
@@ -20,14 +23,29 @@ class Options implements \Magento\Framework\Data\OptionSourceInterface
20
23
*/
21
24
protected $ paymentHelper ;
22
25
26
+ /**
27
+ * @var PaymentMethodListInterface
28
+ */
29
+ private $ paymentMethodList ;
30
+
31
+ /**
32
+ * @var StoreManagerInterface
33
+ */
34
+ private $ storeManager ;
35
+
23
36
/**
24
37
* Constructor
25
38
*
26
39
* @param \Magento\Payment\Helper\Data $paymentHelper
27
40
*/
28
- public function __construct (\Magento \Payment \Helper \Data $ paymentHelper )
29
- {
41
+ public function __construct (
42
+ \Magento \Payment \Helper \Data $ paymentHelper ,
43
+ \Magento \Payment \Api \PaymentMethodListInterface $ paymentMethodList ,
44
+ \Magento \Store \Model \StoreManagerInterface $ storeManager
45
+ ) {
30
46
$ this ->paymentHelper = $ paymentHelper ;
47
+ $ this ->paymentMethodList = $ paymentMethodList ;
48
+ $ this ->storeManager = $ storeManager ;
31
49
}
32
50
33
51
/**
@@ -38,8 +56,23 @@ public function __construct(\Magento\Payment\Helper\Data $paymentHelper)
38
56
public function toOptionArray ()
39
57
{
40
58
if ($ this ->options === null ) {
41
- $ this ->options = $ this ->paymentHelper ->getPaymentMethodList (true , true );
59
+ $ this ->options = $ this ->getPaymentOptions ();
60
+ // $this->options = $this->paymentHelper->getPaymentMethodList(true, true);
42
61
}
43
62
return $ this ->options ;
44
63
}
64
+
65
+ /**
66
+ * @return array
67
+ * @throws \Magento\Framework\Exception\NoSuchEntityException
68
+ */
69
+ private function getPaymentOptions ()
70
+ {
71
+ $ options = [];
72
+ foreach ($ this ->paymentMethodList ->getList ($ this ->storeManager ->getStore ()->getId ()) as $ option ) {
73
+ $ options [$ option ->getCode ()] = ['value ' => $ option ->getCode (), 'label ' => $ option ->getTitle ()];
74
+ }
75
+ asort ($ options );
76
+ return $ options ;
77
+ }
45
78
}
0 commit comments