Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/old/vendor/redchamps/module-core/Model/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/redchamps/module-core/Model/ConfigReader.php
<?php
/**
 * Created by RedChamps.
 * User: rav
 * Date: 2018-12-14
 * Time: 17:11
 */
namespace RedChamps\Core\Model;

use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\DataObject;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Store\Model\ScopeInterface;
use Magento\Store\Model\StoreManagerInterface;

/*
 * Package: Core
 * Class: ConfigReader
 * Company: RedChamps
 * author: rav([email protected])
 * */
class ConfigReader
{

    /**
     * @var StoreManagerInterface
     */
    protected $_storeManager;

    /**
     * @var int
     */
    protected $_storeId;

    protected $_config;

    protected $scopeConfig;

    /**
     * @param StoreManagerInterface $storeManager
     * @param ScopeConfigInterface $scopeConfig
     */
    public function __construct(
        StoreManagerInterface $storeManager,
        ScopeConfigInterface $scopeConfig
    ) {
        $this->_storeManager = $storeManager;
        $this->scopeConfig = $scopeConfig;
    }

    /**
     * Get store config
     *
     * @param $configBasePath
     * @param string $scope
     * @param null $storeId
     * @return object
     * @throws NoSuchEntityException
     */
    public function getConfig($configBasePath, $scope = ScopeInterface::SCOPE_STORE, $storeId = null)
    {
        if (!$this->_config) {
            if (!$storeId) {
                $storeId = $this->getStoreId();
            }

            $configs = $this->scopeConfig->getValue(
                $configBasePath,
                $scope,
                $storeId
            );
            $settings = [];
            foreach ($configs as $node => $config) {
                $settings[$node] = new DataObject($config);
            }
            $this->_config = new DataObject($settings);
        }
        return $this->_config;
    }

    /**
     * Get current store id
     *
     * @return int
     * @throws NoSuchEntityException
     */
    public function getStoreId()
    {
        if ($this->_storeId === null) {
            $this->_storeId = (int)($this->_storeManager->getStore()->getId());
        }

        return $this->_storeId;
    }
}

Spamworldpro Mini