Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CcConfig.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Payment\Model;
7 
12 use Psr\Log\LoggerInterface;
14 
21 class CcConfig
22 {
26  protected $config;
27 
31  protected $assetRepo;
32 
36  protected $request;
37 
41  protected $urlBuilder;
42 
46  protected $logger;
47 
55  public function __construct(
56  PaymentConfig $paymentConfig,
60  LoggerInterface $logger
61  ) {
62  $this->config = $paymentConfig;
63  $this->assetRepo = $assetRepo;
64  $this->request = $request;
65  $this->urlBuilder = $urlBuilder;
66  $this->logger = $logger;
67  }
68 
75  public function getSsStartYears()
76  {
77  $years = [];
78  $first = date("Y");
79 
80  for ($index = 5; $index >= 0; $index--) {
81  $year = $first - $index;
82  $years[$year] = $year;
83  }
84  return $years;
85  }
86 
92  public function getCcAvailableTypes()
93  {
94  return $this->config->getCcTypes();
95  }
96 
102  public function getCcMonths()
103  {
104  return $this->config->getMonths();
105  }
106 
112  public function getCcYears()
113  {
114  return $this->config->getYears();
115  }
116 
122  public function hasVerification()
123  {
124  return true;
125  }
126 
133  public function hasSsCardType()
134  {
135  return false;
136  }
137 
143  public function getCvvImageUrl()
144  {
145  return $this->getViewFileUrl('Magento_Checkout::cvv.png');
146  }
147 
155  public function getViewFileUrl($fileId, array $params = [])
156  {
157  try {
158  $params = array_merge(['_secure' => $this->request->isSecure()], $params);
159  return $this->assetRepo->getUrlWithParams($fileId, $params);
160  } catch (LocalizedException $e) {
161  $this->logger->critical($e);
162  return $this->urlBuilder->getUrl('', ['_direct' => 'core/index/notFound']);
163  }
164  }
165 
173  public function createAsset($fileId, array $params = [])
174  {
175  $params = array_merge(['_secure' => $this->request->isSecure()], $params);
176  return $this->assetRepo->createAsset($fileId, $params);
177  }
178 }
__construct(PaymentConfig $paymentConfig, Repository $assetRepo, RequestInterface $request, UrlInterface $urlBuilder, LoggerInterface $logger)
Definition: CcConfig.php:55
getViewFileUrl($fileId, array $params=[])
Definition: CcConfig.php:155
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18
$index
Definition: list.phtml:44
createAsset($fileId, array $params=[])
Definition: CcConfig.php:173