diff options
Diffstat (limited to 'app/Core/Template.php')
-rw-r--r-- | app/Core/Template.php | 59 |
1 files changed, 20 insertions, 39 deletions
diff --git a/app/Core/Template.php b/app/Core/Template.php index 8ded6f7c..fa7b65ec 100644 --- a/app/Core/Template.php +++ b/app/Core/Template.php @@ -3,63 +3,50 @@ namespace Kanboard\Core; /** - * Template class + * Template * * @package core * @author Frederic Guillot */ -class Template extends Helper +class Template { /** - * List of template overrides + * Helper object * * @access private - * @var array + * @var Helper */ - private $overrides = array(); + private $helper; /** - * Rendering start time - * - * @access private - * @var float - */ - private $startTime = 0; - - /** - * Total rendering time + * List of template overrides * * @access private - * @var float + * @var array */ - private $renderingTime = 0; + private $overrides = array(); /** - * Method executed before the rendering + * Template constructor * - * @access protected - * @param string $template + * @access public + * @param Helper $helper */ - protected function beforeRender($template) + public function __construct(Helper $helper) { - if (DEBUG) { - $this->startTime = microtime(true); - } + $this->helper = $helper; } /** - * Method executed after the rendering + * Expose helpers with magic getter * - * @access protected - * @param string $template + * @access public + * @param string $helper + * @return mixed */ - protected function afterRender($template) + public function __get($helper) { - if (DEBUG) { - $duration = microtime(true) - $this->startTime; - $this->renderingTime += $duration; - $this->container['logger']->debug('Rendering '.$template.' in '.$duration.'s, total='.$this->renderingTime); - } + return $this->helper->getHelper($helper); } /** @@ -76,16 +63,10 @@ class Template extends Helper */ public function render($__template_name, array $__template_args = array()) { - $this->beforeRender($__template_name); - extract($__template_args); ob_start(); include $this->getTemplateFile($__template_name); - $html = ob_get_clean(); - - $this->afterRender($__template_name); - - return $html; + return ob_get_clean(); } /** |