/
githubmirror
/
magento2
Обзор
Документация
Войти
/
githubmirror
/
magento2
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
2.4-develop
lib/internal/Magento/Framework/App/Config.php
137 строк
3 KB
engcom-Dash
39199: fix static failures
16 дек 2024, 12:24
16 дек 2024, 12:24
7954b26
Код
Авторство
О чём код?
<?php /** * Copyright 2013 Adobe * All Rights Reserved. */ namespace Magento\Framework\App; use Magento\Framework\App\Config\ConfigTypeInterface; use Magento\Framework\App\Config\ScopeCodeResolver; use Magento\Framework\App\Config\ScopeConfigInterface; /** * Application configuration object. Used to access configuration when application is initialized and installed. */ class Config implements ScopeConfigInterface { /** * Config cache tag */ public const CACHE_TAG = 'CONFIG'; /** * @var ScopeCodeResolver */ private $scopeCodeResolver; /** * @var ConfigTypeInterface[] */ private $types; /** * Config constructor. * * @param ScopeCodeResolver $scopeCodeResolver * @param array $types */ public function __construct( ScopeCodeResolver $scopeCodeResolver, array $types = [] ) { $this->scopeCodeResolver = $scopeCodeResolver; $this->types = $types; } /** * @inheritDoc */ public function getValue( $path = null, $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeCode = null ) { if ($scope === 'store') { $scope = 'stores'; } elseif ($scope === 'website') { $scope = 'websites'; } $configPath = $scope; if ($scope !== 'default') { if (is_numeric($scopeCode) || $scopeCode === null) { $scopeCode = $this->scopeCodeResolver->resolve($scope, $scopeCode); } elseif ($scopeCode instanceof \Magento\Framework\App\ScopeInterface) { $scopeCode = $scopeCode->getCode(); } if ($scopeCode) { $configPath .= '/' . $scopeCode; } } if ($path) { $configPath .= '/' . $path; } return $this->get('system', $configPath); } /** * @inheritDoc */ public function isSetFlag($path, $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $scopeCode = null) { return !!$this->getValue($path, $scope, $scopeCode); } /** * Invalidate cache by type * * Clean scopeCodeResolver * * @return void */ public function clean() { foreach ($this->types as $type) { $type->clean(); } $this->scopeCodeResolver->clean(); } /** * 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 * * @param string $configType * @param string|null $path * @param mixed|null $default * @return array */ public function get($configType, $path = '', $default = null) { $result = null; if (isset($this->types[$configType])) { $result = $this->types[$configType]->get($path); } return $result !== null ? $result : $default; } /** * Disable show internals with var_dump * * @see https://www.php.net/manual/en/language.oop5.magic.php#object.debuginfo * @return array */ public function __debugInfo() { return []; } }