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
8 namespace Magento\Framework\App;
9 
13 
17 class Config implements ScopeConfigInterface
18 {
22  const CACHE_TAG = 'CONFIG';
23 
27  private $scopeCodeResolver;
28 
32  private $types;
33 
40  public function __construct(
41  ScopeCodeResolver $scopeCodeResolver,
42  array $types = []
43  ) {
44  $this->scopeCodeResolver = $scopeCodeResolver;
45  $this->types = $types;
46  }
47 
56  public function getValue(
57  $path = null,
59  $scopeCode = null
60  ) {
61  if ($scope === 'store') {
62  $scope = 'stores';
63  } elseif ($scope === 'website') {
64  $scope = 'websites';
65  }
66  $configPath = $scope;
67  if ($scope !== 'default') {
68  if (is_numeric($scopeCode) || $scopeCode === null) {
69  $scopeCode = $this->scopeCodeResolver->resolve($scope, $scopeCode);
70  } elseif ($scopeCode instanceof \Magento\Framework\App\ScopeInterface) {
71  $scopeCode = $scopeCode->getCode();
72  }
73  if ($scopeCode) {
74  $configPath .= '/' . $scopeCode;
75  }
76  }
77  if ($path) {
78  $configPath .= '/' . $path;
79  }
80  return $this->get('system', $configPath);
81  }
82 
91  public function isSetFlag($path, $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeCode = null)
92  {
93  return !!$this->getValue($path, $scope, $scopeCode);
94  }
95 
102  public function clean()
103  {
104  foreach ($this->types as $type) {
105  $type->clean();
106  }
107  $this->scopeCodeResolver->clean();
108  }
109 
127  public function get($configType, $path = '', $default = null)
128  {
129  $result = null;
130  if (isset($this->types[$configType])) {
131  $result = $this->types[$configType]->get($path);
132  }
133 
134  return $result !== null ? $result : $default;
135  }
136 }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
isSetFlag($path, $scope=ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeCode=null)
Definition: Config.php:91
$type
Definition: item.phtml:13
__construct(ScopeCodeResolver $scopeCodeResolver, array $types=[])
Definition: Config.php:40
getValue( $path=null, $scope=ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeCode=null)
Definition: Config.php:56