mod for Oxid 7.0
This commit is contained in:
parent
ba687d58e6
commit
7b32b264d0
11
Application/Model/Constants.php
Normal file
11
Application/Model/Constants.php
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace ProudSourcing\CacheWarmer\Application\Model;
|
||||||
|
|
||||||
|
|
||||||
|
class Constants
|
||||||
|
{
|
||||||
|
public const OXID_MODULE_ID = 'psCacheWarmer';
|
||||||
|
}
|
@ -14,6 +14,10 @@
|
|||||||
namespace ProudCommerce\CacheWarmer\Core;
|
namespace ProudCommerce\CacheWarmer\Core;
|
||||||
|
|
||||||
use OxidEsales\Eshop\Core\Registry;
|
use OxidEsales\Eshop\Core\Registry;
|
||||||
|
use OxidEsales\Eshop\Core\ViewConfig;
|
||||||
|
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
||||||
|
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
|
||||||
|
use ProudSourcing\CacheWarmer\Application\Model\Constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class CacheWarmer
|
* Class CacheWarmer
|
||||||
@ -32,7 +36,7 @@ class CacheWarmer
|
|||||||
$this->sCliSiteMapFile = trim($sFileSitemap);
|
$this->sCliSiteMapFile = trim($sFileSitemap);
|
||||||
|
|
||||||
$aUrls = $this->_getSitemapContent();
|
$aUrls = $this->_getSitemapContent();
|
||||||
if ((!empty(Registry::getConfig()->getShopConfVar('psCacheWarmerSitemapUrl'))
|
if ((!empty($this->getModulConfigurationAsString('psCacheWarmerSitemapUrl',Constants::OXID_MODULE_ID))
|
||||||
|| !empty($sFileSitemap))
|
|| !empty($sFileSitemap))
|
||||||
&& !empty($aUrls)) {
|
&& !empty($aUrls)) {
|
||||||
foreach ($aUrls as $sUrl) {
|
foreach ($aUrls as $sUrl) {
|
||||||
@ -56,8 +60,8 @@ class CacheWarmer
|
|||||||
curl_setopt($oCurl, CURLOPT_CONNECTTIMEOUT, 25);
|
curl_setopt($oCurl, CURLOPT_CONNECTTIMEOUT, 25);
|
||||||
curl_setopt($oCurl, CURLOPT_HEADER, true);
|
curl_setopt($oCurl, CURLOPT_HEADER, true);
|
||||||
curl_setopt($oCurl, CURLOPT_USERAGENT, 'CacheWarmer');
|
curl_setopt($oCurl, CURLOPT_USERAGENT, 'CacheWarmer');
|
||||||
$sUsername = Registry::getConfig()->getShopConfVar('psCacheWarmerUser');
|
$sUsername = $this->getModulConfigurationAsString('psCacheWarmerUser',Constants::OXID_MODULE_ID);
|
||||||
$sPassword = Registry::getConfig()->getShopConfVar('psCacheWarmerPass');
|
$sPassword = $this->getModulConfigurationAsString('psCacheWarmerPass',Constants::OXID_MODULE_ID);
|
||||||
curl_setopt($oCurl, CURLOPT_USERPWD, $sUsername . ":" . $sPassword);
|
curl_setopt($oCurl, CURLOPT_USERPWD, $sUsername . ":" . $sPassword);
|
||||||
curl_exec($oCurl);
|
curl_exec($oCurl);
|
||||||
|
|
||||||
@ -76,7 +80,7 @@ class CacheWarmer
|
|||||||
$sMessage = curl_error($oCurl);
|
$sMessage = curl_error($oCurl);
|
||||||
} else {
|
} else {
|
||||||
$sMessage = $sUrl;
|
$sMessage = $sUrl;
|
||||||
if (in_array(trim($httpStatus), Registry::getConfig()->getShopConfVar('psCacheWarmerHttpCodes'))) {
|
if (in_array(trim($httpStatus), $this->getModulConfigurationAsCollection('psCacheWarmerHttpCodes',Constants::OXID_MODULE_ID))) {
|
||||||
$sStatusMsg = 'OK';
|
$sStatusMsg = 'OK';
|
||||||
} else {
|
} else {
|
||||||
$sStatusMsg = 'ERROR';
|
$sStatusMsg = 'ERROR';
|
||||||
@ -86,7 +90,8 @@ class CacheWarmer
|
|||||||
$aLog = [$sStatusMsg, $httpStatus, $sMessage];
|
$aLog = [$sStatusMsg, $httpStatus, $sMessage];
|
||||||
print_r($aLog);
|
print_r($aLog);
|
||||||
|
|
||||||
if (!empty($aLog) && ((Registry::getConfig()->getShopConfVar('psCacheWarmerWriteCsvOnlyError') == true && $httpStatus != '200') || Registry::getConfig()->getShopConfVar('psCacheWarmerWriteCsv') == true)) {
|
if (!empty($aLog) && (($this->getModulConfigurationAsBool('psCacheWarmerWriteCsvOnlyError', Constants::OXID_MODULE_ID) && $httpStatus != '200')
|
||||||
|
|| $this->getModulConfigurationAsBool('psCacheWarmerWriteCsv', Constants::OXID_MODULE_ID))) {
|
||||||
$logger = Logging::getLogger('psCacheWarmer', Registry::getConfig()->getLogsDir() . 'pscachewarmer_' . date("dmY_His") . '.log');
|
$logger = Logging::getLogger('psCacheWarmer', Registry::getConfig()->getLogsDir() . 'pscachewarmer_' . date("dmY_His") . '.log');
|
||||||
$logger->info(implode(' | ', $aLog) . "\r");
|
$logger->info(implode(' | ', $aLog) . "\r");
|
||||||
}
|
}
|
||||||
@ -108,8 +113,8 @@ class CacheWarmer
|
|||||||
{
|
{
|
||||||
$sSitemapUrl = $this->_getSitemapUrl($this->sCliSiteMapFile);
|
$sSitemapUrl = $this->_getSitemapUrl($this->sCliSiteMapFile);
|
||||||
}
|
}
|
||||||
$sUsername = Registry::getConfig()->getShopConfVar('psCacheWarmerUser');
|
$sUsername = $this->getModulConfigurationAsString('psCacheWarmerUser',Constants::OXID_MODULE_ID);
|
||||||
$sPassword = Registry::getConfig()->getShopConfVar('psCacheWarmerPass');
|
$sPassword = $this->getModulConfigurationAsString('psCacheWarmerPass',Constants::OXID_MODULE_ID);
|
||||||
$sSitemapUrl = str_replace("://", "://" . $sUsername . ":" . $sPassword . "@", $sSitemapUrl);
|
$sSitemapUrl = str_replace("://", "://" . $sUsername . ":" . $sPassword . "@", $sSitemapUrl);
|
||||||
|
|
||||||
$sSitemapXmlData = @file_get_contents($sSitemapUrl);
|
$sSitemapXmlData = @file_get_contents($sSitemapUrl);
|
||||||
@ -143,10 +148,70 @@ class CacheWarmer
|
|||||||
$sSitemapUrl .= $sSitemapFile;
|
$sSitemapUrl .= $sSitemapFile;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$sSitemapUrl .= Registry::getConfig()->getShopConfVar('psCacheWarmerSitemapUrl');
|
$sSitemapUrl .= $this->getModulConfigurationAsString('psCacheWarmerSitemapUrl',Constants::OXID_MODULE_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $sSitemapUrl;
|
return $sSitemapUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $sParam
|
||||||
|
* @param string $sModulId
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function getModulConfigurationExists(string $sParam, string $sModulId)
|
||||||
|
{
|
||||||
|
return Registry::get(ViewConfig::class)->d3GetModulConfigurationExists($sParam, $sModulId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $sParam
|
||||||
|
* @param string $sModulId
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getModulConfigurationAsString_(string $sParam, string $sModulId)
|
||||||
|
{
|
||||||
|
return Registry::get(ViewConfig::class)->d3GetModulConfigurationAsString($sParam, $sModulId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* @param string $sParam
|
||||||
|
* @param string $sModulId
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getModulConfigurationAsInteger(string $sParam, string $sModulId)
|
||||||
|
{
|
||||||
|
return Registry::get(ViewConfig::class)->d3GetModulConfigurationAsInteger($sParam, $sModulId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $sParam
|
||||||
|
* @param string $sModulId
|
||||||
|
* @return float
|
||||||
|
*/
|
||||||
|
public function getModulConfigurationAsFloat(string $sParam, string $sModulId)
|
||||||
|
{
|
||||||
|
return Registry::get(ViewConfig::class)->d3GetModulConfigurationAsFloat($sParam, $sModulId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $sParam
|
||||||
|
* @param string $sModulId
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function getModulConfigurationAsBool(string $sParam, string $sModulId)
|
||||||
|
{
|
||||||
|
#return $this->d3getModulConfigurationAsBool($sParam, $sModulId);
|
||||||
|
return Registry::get(ViewConfig::class)->d3GetModulConfigurationAsBool($sParam, $sModulId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $sParam
|
||||||
|
* @param string $sModulId
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getModulConfigurationAsCollection(string $sParam, string $sModulId)
|
||||||
|
{
|
||||||
|
return Registry::get(ViewConfig::class)->d3GetModulConfigurationAsCollection($sParam, $sModulId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
@ -27,6 +27,7 @@ if (!$sFileSiteMap) {
|
|||||||
}
|
}
|
||||||
require_once dirname(__FILE__) . '/../../../../bootstrap.php';
|
require_once dirname(__FILE__) . '/../../../../bootstrap.php';
|
||||||
|
|
||||||
|
use OxidEsales\Eshop\Core\Config;
|
||||||
use OxidEsales\Eshop\Core\Registry;
|
use OxidEsales\Eshop\Core\Registry;
|
||||||
use ProudCommerce\CacheWarmer\Core\CacheWarmer;
|
use ProudCommerce\CacheWarmer\Core\CacheWarmer;
|
||||||
|
|
@ -17,16 +17,12 @@
|
|||||||
"email": "support@proudcommerce.com"
|
"email": "support@proudcommerce.com"
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">= 7.0"
|
"php": ">= 8.0",
|
||||||
|
"oxid-esales/oxideshop-ce": ">=7.0"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"ProudCommerce\\CacheWarmer\\": "../../../source/modules/pc/cachewarmer"
|
"ProudCommerce\\CacheWarmer\\": ""
|
||||||
}
|
|
||||||
},
|
|
||||||
"extra": {
|
|
||||||
"oxideshop": {
|
|
||||||
"target-directory": "pc/cachewarmer"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
/**
|
/**
|
||||||
* Metadata version
|
* Metadata version
|
||||||
*/
|
*/
|
||||||
$sMetadataVersion = '2.0';
|
$sMetadataVersion = '2.1';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Module information
|
* Module information
|
||||||
@ -27,7 +27,7 @@ $aModule = [
|
|||||||
'en' => 'Automatically calling urls using the xml-sitemap, eg. for cache warmup.',
|
'en' => 'Automatically calling urls using the xml-sitemap, eg. for cache warmup.',
|
||||||
],
|
],
|
||||||
'thumbnail' => 'logo_pc-os.jpg',
|
'thumbnail' => 'logo_pc-os.jpg',
|
||||||
'version' => '3.1.2',
|
'version' => '3.2.0',
|
||||||
'author' => 'ProudCommerce',
|
'author' => 'ProudCommerce',
|
||||||
'url' => 'https://github.com/proudcommerce/psCacheWarmer',
|
'url' => 'https://github.com/proudcommerce/psCacheWarmer',
|
||||||
'email' => '',
|
'email' => '',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user