b374k
m1n1 1.01
Apache/2.4.41 (Ubuntu)
Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64
uid=33(www-data) gid=33(www-data) groups=33(www-data)
server ip : 62.171.164.128 | your ip : 127.0.0.1
safemode OFF
 >  / home / dev2.destoffenstraat.com / vendor / amasty / base / Model /
Filename/home/dev2.destoffenstraat.com/vendor/amasty/base/Model/ConfigProviderAbstract.php
Size3.04 kb
Permissionrw-r--r--
Ownerroot : root
Create time17-Aug-2025 10:26
Last modified16-Aug-2022 09:35
Last accessed22-Aug-2025 21:53
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
<?php
/**
* @author Amasty Team
* @copyright Copyright (c) 2022 Amasty (https://www.amasty.com)
* @package Magento 2 Base Package
*/

namespace Amasty\Base\Model;

use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Store\Model\ScopeInterface;

/**
* @since 1.4.4
* @since 1.12.9 fixed cache for emulated store
*/
abstract class ConfigProviderAbstract
{
/**
* xpath prefix of module (section)
* @var string '{section}/'
*/
protected $pathPrefix = '/';

/**
* @var ScopeConfigInterface
*/
protected $scopeConfig;

/**
* Stored values by scopes
*
* @var array
*/
protected $data = [];

/**
* ConfigProviderAbstract constructor.
*
* @param ScopeConfigInterface $scopeConfig
*
* @throws \LogicException
*/
public function __construct(ScopeConfigInterface $scopeConfig)
{
$this->scopeConfig = $scopeConfig;
if ($this->pathPrefix === '/') {
throw new \LogicException('$pathPrefix should be declared');
}
}

/**
* clear local storage
*
* @return void
*/
public function clean()
{
$this->data = [];
}

/**
* An alias for scope config with default scope type SCOPE_STORE
*
* @param string $path '{group}/{field}'
* @param int|ScopeInterface|null $storeId Scope code
* @param string $scope
*
* @return mixed
*/
protected function getValue(
$path,
$storeId = null,
$scope = ScopeInterface::SCOPE_STORE
) {
if ($storeId === null && $scope !== ScopeConfigInterface::SCOPE_TYPE_DEFAULT) {
return $this->scopeConfig->getValue($this->pathPrefix . $path, $scope, $storeId);
}

if ($storeId instanceof \Magento\Framework\App\ScopeInterface) {
$storeId = $storeId->getId();
}
$scopeKey = $storeId . $scope;
if (!isset($this->data[$path]) || !\array_key_exists($scopeKey, $this->data[$path])) {
$this->data[$path][$scopeKey] = $this->scopeConfig->getValue($this->pathPrefix . $path, $scope, $storeId);
}

return $this->data[$path][$scopeKey];
}

/**
* An alias for scope config with scope type Default
*
* @param string $path '{group}/{field}'
*
* @return mixed
*/
protected function getGlobalValue($path)
{
return $this->getValue($path, null, ScopeConfigInterface::SCOPE_TYPE_DEFAULT);
}

/**
* @param string $path '{group}/{field}'
* @param int|ScopeInterface|null $storeId
* @param string $scope
*
* @return bool
*/
protected function isSetFlag(
$path,
$storeId = null,
$scope = ScopeInterface::SCOPE_STORE
) {
return (bool)$this->getValue($path, $storeId, $scope);
}

/**
* @param string $path '{group}/{field}'
*
* @return bool
*/
protected function isSetGlobalFlag($path)
{
return $this->isSetFlag($path, null, ScopeConfigInterface::SCOPE_TYPE_DEFAULT);
}
}