Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Config.php
Go to the documentation of this file.
1 <?php
7 
14 class Config
15 {
19  private $_servicesConfig;
20 
27  public function __construct(array $servicesConfig)
28  {
29  foreach ($servicesConfig as $serviceName => $serviceInfo) {
30  if (!is_string($serviceName) || empty($serviceName)) {
31  throw new \InvalidArgumentException('Name for a currency import service has to be specified.');
32  }
33  if (empty($serviceInfo['class'])) {
34  throw new \InvalidArgumentException('Class for a currency import service has to be specified.');
35  }
36  if (empty($serviceInfo['label'])) {
37  throw new \InvalidArgumentException('Label for a currency import service has to be specified.');
38  }
39  }
40  $this->_servicesConfig = $servicesConfig;
41  }
42 
48  public function getAvailableServices()
49  {
50  return array_keys($this->_servicesConfig);
51  }
52 
59  public function getServiceClass($serviceName)
60  {
61  if (isset($this->_servicesConfig[$serviceName]['class'])) {
62  return $this->_servicesConfig[$serviceName]['class'];
63  }
64  return null;
65  }
66 
73  public function getServiceLabel($serviceName)
74  {
75  if (isset($this->_servicesConfig[$serviceName]['label'])) {
76  return __($this->_servicesConfig[$serviceName]['label']);
77  }
78  return null;
79  }
80 }
__()
Definition: __.php:13