Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Data Structures | Public Member Functions | Data Fields
Config Class Reference
Inheritance diagram for Config:
ScopeConfigInterface MutableScopeConfig Config ReinitableConfig

Data Structures

class  BaseTest
 
class  DataTest
 
class  InitialTest
 

Public Member Functions

 __construct (ScopeCodeResolver $scopeCodeResolver, array $types=[])
 
 getValue ( $path=null, $scope=ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeCode=null)
 
 isSetFlag ($path, $scope=ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeCode=null)
 
 clean ()
 
 get ($configType, $path='', $default=null)
 

Data Fields

const CACHE_TAG = 'CONFIG'
 
- Data Fields inherited from ScopeConfigInterface
const SCOPE_TYPE_DEFAULT = 'default'
 

Detailed Description

Class Config

Definition at line 17 of file Config.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( ScopeCodeResolver  $scopeCodeResolver,
array  $types = [] 
)

Config constructor.

Parameters
ScopeCodeResolver$scopeCodeResolver
array$types

Definition at line 40 of file Config.php.

43  {
44  $this->scopeCodeResolver = $scopeCodeResolver;
45  $this->types = $types;
46  }

Member Function Documentation

◆ clean()

clean ( )

Invalidate cache by type Clean scopeCodeResolver

Returns
void

Definition at line 102 of file Config.php.

103  {
104  foreach ($this->types as $type) {
105  $type->clean();
106  }
107  $this->scopeCodeResolver->clean();
108  }
$type
Definition: item.phtml:13

◆ get()

get (   $configType,
  $path = '',
  $default = null 
)

Retrieve configuration.

('modules') - modules status configuration data ('scopes', 'websites/base') - base website data ('scopes', 'stores/default') - default store data

('system', 'default/web/seo/use_rewrites') - default system configuration data ('system', 'websites/base/web/seo/use_rewrites') - 'base' website system configuration data

('i18n', 'default/en_US') - translations for default store and 'en_US' locale

Parameters
string$configType
string | null$path
mixed | null$default
Returns
array

Definition at line 127 of file Config.php.

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  }

◆ getValue()

getValue (   $path = null,
  $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
  $scopeCode = null 
)

Retrieve config value by path and scope

Parameters
string$path
string$scope
null | string$scopeCode
Returns
mixed

Implements ScopeConfigInterface.

Definition at line 56 of file Config.php.

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  }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17

◆ isSetFlag()

isSetFlag (   $path,
  $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
  $scopeCode = null 
)

Retrieve config flag

Parameters
string$path
string$scope
null | string$scopeCode
Returns
bool

Implements ScopeConfigInterface.

Definition at line 91 of file Config.php.

92  {
93  return !!$this->getValue($path, $scope, $scopeCode);
94  }
getValue( $path=null, $scope=ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeCode=null)
Definition: Config.php:56

Field Documentation

◆ CACHE_TAG

const CACHE_TAG = 'CONFIG'

Config cache tag

Definition at line 22 of file Config.php.


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