Files
smarty/libs/sysplugins/method.register_function.php
Uwe.Tews d2d8c8925b - removed all internal calls of Smarty::instance()
- fixed code in double quoted strings
2009-08-08 17:28:23 +00:00

34 lines
951 B
PHP

<?php
/**
* Smarty method Register_Function
*
* Registers a PHP function as Smarty function plugin
*
* @package Smarty
* @subpackage SmartyMethod
* @author Uwe Tews
*/
/**
* Registers custom function to be used in templates
*
* @param object $smarty
* @param string $function_tag the name of the template function
* @param string $function_impl the name of the PHP function to register
* @param boolean $cacheable if true (default) this fuction is cachable
*/
function register_function($smarty, $function_tag, $function_impl, $cacheable = true)
{
if (isset($smarty->registered_plugins[$function_tag])) {
throw new Exception("Plugin tag \"{$function_tag}\" already registered");
} elseif (!is_callable($function_impl)) {
throw new Exception("Plugin \"{$function_tag}\" not callable");
} else {
$smarty->registered_plugins[$function_tag] =
array('function', $function_impl, $cacheable);
}
}
?>