Tpl: add register_class method and make App class available in templates

This commit is contained in:
Benjamin Renard 2023-03-02 15:02:59 +01:00
parent 5ca3208c91
commit 80f41c5327
Signed by: bn8
GPG key ID: 3E2E1CE1907115BC

View file

@ -177,9 +177,9 @@ class Tpl {
foreach(App :: get('templates.static_directories', null, 'array') as $path)
self :: register_static_directory($path);
self :: register_function('var_dump', array('EesyPHP\\Tpl', 'smarty_var_dump'));
}
self :: register_function('var_dump', array('EesyPHP\\Tpl', 'smarty_var_dump'));
self :: register_class('App', '\\EesyPHP\\App');
}
/**
@ -223,6 +223,16 @@ class Tpl {
self :: $smarty -> registerPlugin("function", $name, $callable);
}
/**
* Register a class usable from template files
* @param string $class_name The class name
* @param string $class_ref The class reference (eg: \EesyPHP\App)
* @return void
*/
public static function register_class($class_name, $class_ref) {
self :: $smarty -> registerClass($class_name, $class_ref);
}
/**
* Assign template variable
* @param string $name The variable name