Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
PaymentMethodList.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Vault\Model;
7 
12 use Magento\Vault\Api\PaymentMethodListInterface as VaultPaymentMethodListInterface;
13 
17 class PaymentMethodList implements VaultPaymentMethodListInterface
18 {
22  private $instanceFactory;
23 
27  private $paymentMethodList;
28 
34  public function __construct(PaymentMethodListInterface $paymentMethodList, InstanceFactory $instanceFactory)
35  {
36  $this->instanceFactory = $instanceFactory;
37  $this->paymentMethodList = $paymentMethodList;
38  }
39 
43  public function getList($storeId)
44  {
45  return $this->filterList($this->paymentMethodList->getList($storeId));
46  }
47 
51  public function getActiveList($storeId)
52  {
53  return $this->filterList($this->paymentMethodList->getActiveList($storeId));
54  }
55 
61  private function filterList(array $list)
62  {
63  $paymentMethods = array_map(
64  function (PaymentMethodInterface $paymentMethod) {
65  return $this->instanceFactory->create($paymentMethod);
66  },
67  $list
68  );
69 
70  $availableMethods = array_filter(
72  function (MethodInterface $methodInstance) {
73  return $methodInstance instanceof VaultPaymentInterface;
74  }
75  );
76  return array_values($availableMethods);
77  }
78 }
__construct(PaymentMethodListInterface $paymentMethodList, InstanceFactory $instanceFactory)
$paymentMethods