Refactor Hook class to integrate Page Cache functionality
- Removed legacy code related to 'cookiesplus' module. - Added checks for 'pagecache' module and included its functionality in coreCallHook and coreRenderWidget methods. - Updated module metadata comments to reflect changes and new versioning.
This commit is contained in:
@@ -1,73 +1,42 @@
|
||||
<?php
|
||||
if (!defined('_PS_VERSION_')) {
|
||||
exit;
|
||||
}
|
||||
/**
|
||||
* Page Cache Ultimate, Page Cache standard and Speed pack are powered by Jpresta (jpresta . com)
|
||||
*
|
||||
* @author Jpresta
|
||||
* @copyright Jpresta
|
||||
* @license See the license of this module in file LICENSE.txt, thank you.
|
||||
*/
|
||||
if (!defined('_PS_VERSION_')) {exit;}
|
||||
class Hook extends HookCore
|
||||
{
|
||||
/*
|
||||
* module: cookiesplus
|
||||
* date: 2024-02-06 23:53:48
|
||||
* version: 1.6.0
|
||||
*/
|
||||
public static function getHookModuleExecList($hookName = null)
|
||||
{
|
||||
$modulesToInvoke = parent::getHookModuleExecList($hookName);
|
||||
if (Module::isEnabled('cookiesplus')) {
|
||||
$cookiesPlus = Module::getInstanceByName('cookiesplus');
|
||||
$modulesToInvoke = $cookiesPlus->blockModuleCache($modulesToInvoke, $hookName);
|
||||
}
|
||||
return !empty($modulesToInvoke) ? $modulesToInvoke : false;
|
||||
}
|
||||
/*
|
||||
* module: cookiesplus
|
||||
* date: 2024-02-06 23:53:48
|
||||
* version: 1.6.0
|
||||
* module: pagecache
|
||||
* date: 2025-11-28 11:17:30
|
||||
* version: 9.6.1
|
||||
*/
|
||||
public static function coreCallHook($module, $method, $params)
|
||||
{
|
||||
$headersBeforeExecution = headers_list();
|
||||
$display = parent::coreCallHook($module, $method, $params);
|
||||
if (Module::isEnabled('cookiesplus')) {
|
||||
$forceDisplay = false;
|
||||
$cookiesPlus = Module::getInstanceByName('cookiesplus');
|
||||
$cookiesPlus->blockModuleCode([
|
||||
'display' => &$display,
|
||||
'module' => &$module,
|
||||
'hookName' => &$method,
|
||||
'params' => &$params,
|
||||
'forceDisplay' => &$forceDisplay,
|
||||
'headersBeforeExecution' => $headersBeforeExecution,
|
||||
]);
|
||||
if ($forceDisplay) {
|
||||
return $display;
|
||||
}
|
||||
if (!Module::isEnabled('pagecache') || !file_exists(_PS_MODULE_DIR_ . 'pagecache/pagecache.php')) {
|
||||
return parent::coreCallHook($module, $method, $params);
|
||||
}
|
||||
else {
|
||||
require_once _PS_MODULE_DIR_ . 'pagecache/pagecache.php';
|
||||
return PageCache::execHook(PageCache::HOOK_TYPE_MODULE, $module, $method, $params);
|
||||
}
|
||||
return $display;
|
||||
}
|
||||
/*
|
||||
* module: cookiesplus
|
||||
* date: 2024-02-06 23:53:48
|
||||
* version: 1.6.0
|
||||
* module: pagecache
|
||||
* date: 2025-11-28 11:17:30
|
||||
* version: 9.6.1
|
||||
*/
|
||||
public static function coreRenderWidget($module, $hook_name, $params)
|
||||
{
|
||||
$headersBeforeExecution = headers_list();
|
||||
$display = parent::coreRenderWidget($module, $hook_name, $params);
|
||||
if (Module::isEnabled('cookiesplus')) {
|
||||
$forceDisplay = false;
|
||||
$cookiesPlus = Module::getInstanceByName('cookiesplus');
|
||||
$cookiesPlus->blockModuleCode([
|
||||
'display' => &$display,
|
||||
'module' => &$module,
|
||||
'hookName' => &$hook_name,
|
||||
'params' => &$params,
|
||||
'forceDisplay' => &$forceDisplay,
|
||||
'headersBeforeExecution' => $headersBeforeExecution,
|
||||
]);
|
||||
if ($forceDisplay) {
|
||||
return $display;
|
||||
}
|
||||
if (!Module::isEnabled('pagecache') || !file_exists(_PS_MODULE_DIR_ . 'pagecache/pagecache.php')) {
|
||||
return parent::coreRenderWidget($module, $hook_name, $params);
|
||||
}
|
||||
else {
|
||||
require_once _PS_MODULE_DIR_ . 'pagecache/pagecache.php';
|
||||
return PageCache::execHook(PageCache::HOOK_TYPE_WIDGET, $module, $hook_name, $params);
|
||||
}
|
||||
return $display;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user