mirror of
https://github.com/slawkens/myaac.git
synced 2025-10-13 17:24:54 +02:00
* cache hooks and template menus
This commit is contained in:
@@ -73,10 +73,12 @@ class Hooks
|
||||
$ret = true;
|
||||
if(isset(self::$_hooks[$type]))
|
||||
{
|
||||
foreach(self::$_hooks[$type] as $name => $hook)
|
||||
if(!$hook->execute($params)) {
|
||||
foreach(self::$_hooks[$type] as $name => $hook) {
|
||||
/** @var $hook Hook */
|
||||
if (!$hook->execute($params)) {
|
||||
$ret = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $ret;
|
||||
@@ -89,9 +91,26 @@ class Hooks
|
||||
public function load()
|
||||
{
|
||||
global $db;
|
||||
$hooks = $db->query('SELECT `name`, `type`, `file` FROM `' . TABLE_PREFIX . 'hooks` WHERE `enabled` = 1 ORDER BY `ordering`;');
|
||||
foreach($hooks as $hook)
|
||||
|
||||
$cache = Cache::getInstance();
|
||||
if ($cache->enabled()) {
|
||||
$tmp = '';
|
||||
if ($cache->fetch('hooks', $tmp)) {
|
||||
$hooks = unserialize($tmp);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($hooks)) {
|
||||
$hooks = $db->query('SELECT `name`, `type`, `file` FROM `' . TABLE_PREFIX . 'hooks` WHERE `enabled` = 1 ORDER BY `ordering`;')->fetchAll();
|
||||
|
||||
if ($cache->enabled()) {
|
||||
$cache->set('hooks', serialize($hooks), 600);
|
||||
}
|
||||
}
|
||||
|
||||
foreach($hooks as $hook) {
|
||||
$this->register($hook['name'], $hook['type'], $hook['file']);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user