1 <?php
3 /**
4 * Smarty method Register_Modifier
5 *
6 * Registers a PHP function as Smarty modifier plugin
7 *
8 * @package Smarty
9 * @subpackage SmartyMethod
10 * @author Uwe Tews
11 */
13 /**
14 * Registers modifier to be used in templates
15 *
16 * @param object $smarty
17 * @param string $modifier name of template modifier
18 * @param string $modifier_impl name of PHP function to register
19 */
20 function Smarty_Method_Register_Modifier($smarty, $modifier, $modifier_impl)
21 {
22 if (isset($smarty->registered_plugins['modifier'][$modifier])) {
23 throw new Exception("Plugin \"{$modifier}\" already registered");
24 } elseif (!is_callable($modifier_impl)) {
25 throw new Exception("Plugin \"{$modifier}\" not callable");
26 } else {
27 $smarty->registered_plugins['modifier'][$modifier] =
28 array($modifier_impl);
29 }
30 }
31 ?>