Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 520fa2d

Browse files
jherryaleeks
authored andcommitted
CO: add new hook 'actionClearCache'
1 parent 804fb3a commit 520fa2d

3 files changed

Lines changed: 33 additions & 3 deletions

File tree

classes/Tools.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2980,7 +2980,11 @@ public static function clearCache($smarty = null, $tpl = false, $cache_id = null
29802980
return $smarty->clearAllCache();
29812981
}
29822982

2983-
return $smarty->clearCache($tpl, $cache_id, $compile_id);
2983+
$ret = $smarty->clearCache($tpl, $cache_id, $compile_id);
2984+
2985+
Hook::exec('actionClearCache');
2986+
2987+
return $ret;
29842988
}
29852989

29862990
/**
@@ -2996,7 +3000,11 @@ public static function clearCompile($smarty = null)
29963000
return;
29973001
}
29983002

2999-
return $smarty->clearCompiledTemplate();
3003+
$ret = $smarty->clearCompiledTemplate();
3004+
3005+
Hook::exec('actionClearCompileCache');
3006+
3007+
return $ret;
30003008
}
30013009

30023010
/**
@@ -3020,7 +3028,11 @@ public static function clearSf2Cache($env = null)
30203028

30213029
$sf2Refresh = new Refresh($env);
30223030
$sf2Refresh->addCacheClear();
3023-
return $sf2Refresh->execute();
3031+
$ret = $sf2Refresh->execute();
3032+
3033+
Hook::exec('actionClearSf2Cache');
3034+
3035+
return $ret;
30243036
}
30253037

30263038
/**

install-dev/data/xml/hook.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,21 @@
551551
<title>Display elements after login form</title>
552552
<description>This hook displays new elements after the login form</description>
553553
</hook>
554+
<hook id="actionClearCache">
555+
<name>actionClearCache</name>
556+
<title>Clear smarty cache</title>
557+
<description>This hook is called when smarty's cache is cleared</description>
558+
</hook>
559+
<hook id="actionClearCompileCache">
560+
<name>actionClearCompileCache</name>
561+
<title>Clear smarty compile cache</title>
562+
<description>This hook is called when smarty's compile cache is cleared</description>
563+
</hook>
564+
<hook id="actionClearSf2Cache">
565+
<name>actionClearSf2Cache</name>
566+
<title>Clear Sf2 cache</title>
567+
<description>This hook is called when the Symfony cache is cleared</description>
568+
</hook>
554569
<hook id="actionValidateCustomerAddressForm">
555570
<name>actionValidateCustomerAddressForm</name>
556571
<title>Customer address form validation</title>

install-dev/upgrade/sql/1.7.1.0.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,8 @@ INSERT INTO `PREFIX_hook` (`id_hook`, `name`, `title`, `description`, `position`
6161
(NULL, 'displayAfterProductThumbs', 'Display extra content below product thumbs', 'This hook displays new elements below product images ex. additional media', '1'),
6262
(NULL, 'actionDispatcherBefore', 'Before dispatch', 'This hook is called at the beginning of the dispatch method of the Dispatcher', '1'),
6363
(NULL, 'actionDispatcherAfter', 'After dispatch', 'This hook is called at the end of the dispatch method of the Dispatcher', '1');
64+
(NULL, 'actionClearCache', 'Clear smarty cache', 'This hook is called when the cache of the theme is cleared', '1'),
65+
(NULL, 'actionClearCompileCache', 'Clear smarty compile cache', 'This hook is called when smarty''s compile cache is cleared', '1'),
66+
(NULL, 'actionClearSf2Cache', 'Clear Sf2 cache', 'This hook is called when the Symfony cache is cleared', '1');
6467

6568
DELETE FROM `PREFIX_configuration` WHERE `name` IN ('PS_META_KEYWORDS');

0 commit comments

Comments
 (0)