Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CcConfigProvider.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Payment\Model;
7 
10 
18 {
22  private $icons = [];
23 
27  protected $ccConfig;
28 
32  protected $assetSource;
33 
38  public function __construct(
41  ) {
42  $this->ccConfig = $ccConfig;
43  $this->assetSource = $assetSource;
44  }
45 
49  public function getConfig()
50  {
51  return [
52  'payment' => [
53  'ccform' => [
54  'icons' => $this->getIcons()
55  ]
56  ]
57  ];
58  }
59 
65  public function getIcons()
66  {
67  if (!empty($this->icons)) {
68  return $this->icons;
69  }
70 
71  $types = $this->ccConfig->getCcAvailableTypes();
72  foreach (array_keys($types) as $code) {
73  if (!array_key_exists($code, $this->icons)) {
74  $asset = $this->ccConfig->createAsset('Magento_Payment::images/cc/' . strtolower($code) . '.png');
75  $placeholder = $this->assetSource->findSource($asset);
76  if ($placeholder) {
77  list($width, $height) = getimagesize($asset->getSourceFile());
78  $this->icons[$code] = [
79  'url' => $asset->getUrl(),
80  'width' => $width,
81  'height' => $height
82  ];
83  }
84  }
85  }
86 
87  return $this->icons;
88  }
89 }
__construct(CcConfig $ccConfig, Source $assetSource)
$code
Definition: info.phtml:12