Tpl: add register_class method and make App class available in templates
This commit is contained in:
parent
5ca3208c91
commit
80f41c5327
1 changed files with 12 additions and 2 deletions
14
src/Tpl.php
14
src/Tpl.php
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue