public static function getInstance() { if (!self::$instance) { self::$instance = new self(); } return self::$instance; }
public static function getInstance() { if (!self::$instance) { self::$instance = new SmartyLazyRegister(); } return self::$instance; }
function smartyRegisterFunction($smarty, $type, $function, $params, $lazy = true) { if (!in_array($type, array('function', 'modifier', 'block'))) { return false; } // lazy is better if the function is not called on every page if ($lazy) { $lazy_register = SmartyLazyRegister::getInstance(); if ($lazy_register->isRegistered($params)) { return; } $lazy_register->register($params); if (is_array($params)) { $params = $params[1]; } // SmartyLazyRegister allows to only load external class when they are needed $smarty->registerPlugin($type, $function, array($lazy_register, $params)); } else { $smarty->registerPlugin($type, $function, $params); } }