Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
CcConfigProvider Class Reference
Inheritance diagram for CcConfigProvider:
ConfigProviderInterface

Public Member Functions

 __construct (CcConfig $ccConfig, Source $assetSource)
 
 getConfig ()
 
 getIcons ()
 

Protected Attributes

 $ccConfig
 
 $assetSource
 

Detailed Description

Class CcConfigProvider

@api

Since
100.0.2

Definition at line 17 of file CcConfigProvider.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( CcConfig  $ccConfig,
Source  $assetSource 
)
Parameters
CcConfig$ccConfig
Source$assetSource

Definition at line 38 of file CcConfigProvider.php.

41  {
42  $this->ccConfig = $ccConfig;
43  $this->assetSource = $assetSource;
44  }

Member Function Documentation

◆ getConfig()

getConfig ( )

{Retrieve assoc array of checkout configuration

Returns
array
}

Implements ConfigProviderInterface.

Definition at line 49 of file CcConfigProvider.php.

50  {
51  return [
52  'payment' => [
53  'ccform' => [
54  'icons' => $this->getIcons()
55  ]
56  ]
57  ];
58  }

◆ getIcons()

getIcons ( )

Get icons for available payment methods

Returns
array

Definition at line 65 of file CcConfigProvider.php.

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  }
$code
Definition: info.phtml:12

Field Documentation

◆ $assetSource

$assetSource
protected

Definition at line 32 of file CcConfigProvider.php.

◆ $ccConfig

$ccConfig
protected

Definition at line 27 of file CcConfigProvider.php.


The documentation for this class was generated from the following file: