/** * Called before the controller is deleted. * * The view's render method is called for each view registered. * * @throws ViewException */ public function __destruct() { $this->_output->outputHeader(); if (!$this->_isRenderAction) { if (isset($this->_view)) { if (is_array($this->_view)) { $this->_app->getHookManager()->runBeforeView(array('controller' => $this)); foreach ($this->_view as $view) { $view->render(); } $this->_app->getHookManager()->runAfterView(); } elseif (is_a($this->_view, '\\pff\\AView')) { $this->_app->getHookManager()->runBeforeView(array('controller' => $this)); $this->_view->render(); $this->_app->getHookManager()->runAfterView(); } else { throw new ViewException("The specified View is not valid."); } } } else { if (isset($this->_view)) { if (is_array($this->_view)) { foreach ($this->_view as $view) { $this->_app->getHookManager()->runBeforeView(array('controller' => $this)); $view->render(); } } elseif (is_a($this->_view, '\\pff\\AView')) { $this->_app->getHookManager()->runBeforeView(array('controller' => $this)); $this->_view->render(); } else { throw new ViewException("The specified View is not valid."); } } } }
public function __construct($templateName) { if (substr($templateName, 0, 1) != '/') { $templatePath = ROOT . DS . 'app' . DS . 'views' . DS . $templateName; } else { $templatePath = $templateName; } if (!file_exists($templatePath)) { throw new ViewException('Template file ' . $templatePath . ' does not exist'); } parent::__construct($templateName); }
public function __construct($templateName) { $this->_smarty = new \Smarty(); // The smarty instance should be accessible before $smartyDir = ROOT . DS . 'app' . DS . 'views' . DS . 'smarty' . DS; $this->_smarty->template_dir = $smartyDir . 'templates' . DS; $this->_smarty->compile_dir = $smartyDir . 'compiled_templates' . DS; $this->_smarty->config_dir = $smartyDir . 'configs' . DS; $this->_smarty->cache_dir = $smartyDir . 'cache' . DS; $templatePath = ROOT . DS . 'app' . DS . 'views' . DS . 'smarty' . DS . 'templates' . DS . $templateName; if (!file_exists($templatePath)) { throw new \pff\ViewException('Template file ' . $templatePath . ' does not exist'); } parent::__construct($templateName); $this->_smarty->registerPlugin('function', 'renderAction', array($this, 'smarty_plugin_renderAction')); }