/** * Retrieve config section * * @param string $scopeType * @param string|\Magento\Framework\DataObject|null $scopeCode * @return \Magento\Framework\App\Config\DataInterface */ public function getScope($scopeType, $scopeCode = null) { $scopeCode = $this->_getScopeCode($scopeType, $scopeCode); $code = $scopeType . '|' . $scopeCode; if (!isset($this->_scopes[$code])) { // Key by url to support dynamic {{base_url}} and port assignments $host = $this->getRequest()->getHttpHost(); $port = $this->getRequest()->getServer('SERVER_PORT'); $path = $this->getRequest()->getBasePath(); $urlInfo = $host . $port . trim($path, '/'); $cacheKey = $this->_cacheId . '|' . $code . '|' . $urlInfo; $data = $this->_cache->load($cacheKey); if ($data) { $data = unserialize($data); } else { $reader = $this->_readerPool->getReader($scopeType); if ($scopeType === ScopeConfigInterface::SCOPE_TYPE_DEFAULT) { $data = $reader->read(); } else { $data = $reader->read($scopeCode); } $this->_cache->save(serialize($data), $cacheKey, [self::CACHE_TAG]); } $this->_scopes[$code] = $this->_dataFactory->create(['data' => $data]); } return $this->_scopes[$code]; }
/** * Retrieve config section * * @param string $scopeType * @param string|\Magento\Framework\DataObject|null $scopeCode * @return \Magento\Framework\App\Config\DataInterface */ public function getScope($scopeType, $scopeCode = null) { $scopeCode = $this->_getScopeCode($scopeType, $scopeCode); $code = $scopeType . '|' . $scopeCode; if (!isset($this->_scopes[$code])) { $cacheKey = $this->_cacheId . '|' . $code; $data = $this->_cache->load($cacheKey); if ($data) { $data = unserialize($data); } else { $reader = $this->_readerPool->getReader($scopeType); if ($scopeType === ScopeConfigInterface::SCOPE_TYPE_DEFAULT) { $data = $reader->read(); } else { $data = $reader->read($scopeCode); } $this->_cache->save(serialize($data), $cacheKey, [self::CACHE_TAG]); } $this->_scopes[$code] = $this->_dataFactory->create(['data' => $data]); } return $this->_scopes[$code]; }