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 
11 
19 class Config implements ConfigInterface
20 {
21  const DEFAULT_PATH_PATTERN = 'payment/%s/%s';
22 
26  private $scopeConfig;
27 
31  private $methodCode;
32 
36  private $pathPattern;
37 
43  public function __construct(
44  ScopeConfigInterface $scopeConfig,
45  $methodCode = null,
46  $pathPattern = self::DEFAULT_PATH_PATTERN
47  ) {
48  $this->scopeConfig = $scopeConfig;
49  $this->methodCode = $methodCode;
50  $this->pathPattern = $pathPattern;
51  }
52 
59  public function setMethodCode($methodCode)
60  {
61  $this->methodCode = $methodCode;
62  }
63 
70  public function setPathPattern($pathPattern)
71  {
72  $this->pathPattern = $pathPattern;
73  }
74 
83  public function getValue($field, $storeId = null)
84  {
85  if ($this->methodCode === null || $this->pathPattern === null) {
86  return null;
87  }
88 
89  return $this->scopeConfig->getValue(
90  sprintf($this->pathPattern, $this->methodCode, $field),
92  $storeId
93  );
94  }
95 }
getValue($field, $storeId=null)
Definition: Config.php:83
__construct(ScopeConfigInterface $scopeConfig, $methodCode=null, $pathPattern=self::DEFAULT_PATH_PATTERN)
Definition: Config.php:43