Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
VaultConfigProvider.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Vault\Model\Ui;
7 
13 
21 {
22  const IS_ACTIVE_CODE = 'is_active_payment_token_enabler';
23 
27  private static $vaultCode = 'vault';
28 
32  private $storeManager;
33 
37  private $session;
38 
42  private $vaultPaymentList;
43 
49  public function __construct(
50  StoreManagerInterface $storeManager,
52  ) {
53  $this->storeManager = $storeManager;
54  $this->session = $session;
55  }
56 
63  public function getConfig()
64  {
65  $availableMethods = [];
66  $storeId = $this->storeManager->getStore()->getId();
67  $vaultPayments = $this->getVaultPaymentList()->getActiveList($storeId);
68  $customerId = $this->session->getCustomerId();
69 
70  foreach ($vaultPayments as $method) {
71  $availableMethods[$method->getCode()] = [
72  'is_enabled' => $customerId !== null && $method->isActive($storeId)
73  ];
74  }
75 
76  return [
77  self::$vaultCode => $availableMethods
78  ];
79  }
80 
86  private function getVaultPaymentList()
87  {
88  if ($this->vaultPaymentList === null) {
89  $this->vaultPaymentList = ObjectManager::getInstance()->get(PaymentMethodListInterface::class);
90  }
91  return $this->vaultPaymentList;
92  }
93 }
$storeManager
__construct(StoreManagerInterface $storeManager, SessionManagerInterface $session)
$method
Definition: info.phtml:13