public function testAbsoluteDir() { $obj = new HtmlTemplate(); $obj->setCacheDir('/tmp'); $obj->setProjectTemplateDir(SYNERGY_ROOT_DIR . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'templates'); $obj->setTemplateDir(SYNERGY_ROOT_DIR . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'templates'); $obj->setTemplateFile('index.html'); $obj->init(); }
/** * Display a 404 error or similar * * @param mixed $response any response we can work with * * @throws \Synergy\Exception\NotFoundException */ protected function handleNotFoundException($response = null) { $template = new HtmlTemplate(); $template->setTemplateDir(SYNERGY_LIBRARY_PATH . DIRECTORY_SEPARATOR . 'View' . DIRECTORY_SEPARATOR . '_synergy_'); $template->setTemplateFile('404.html'); // set the template parameters $template->setParameters($this->getTemplateParameters($template)); $template->init(); $response = $template->getWebResponse(); $response->setStatusCode(404); if ($response instanceof WebResponse) { $this->handleWebResponse($response); } else { throw new NotFoundException('Unable to match Request to a Response via a Route'); } }
/** * Look for a template file within the matchDir * * @param string $matchDir * @param string $file * * @return SmartyTemplate|TwigTemplate|HtmlTemplate|null */ protected function matchTemplate($matchDir, $file) { if (file_exists($matchDir . $file . '.tpl') && class_exists('\\Smarty')) { Logger::info('Smarty Template: ' . $file . '.tpl'); $template = new SmartyTemplate(); $template->setTemplateDir($matchDir); $template->setTemplateFile($file . '.tpl'); return $template; } elseif (file_exists($matchDir . $file . '.twig') && class_exists('\\Twig_Environment')) { Logger::info('Twig Template: ' . $file . '.twig'); $template = new TwigTemplate(); $template->setTemplateDir($matchDir); $template->setTemplateFile($file . '.twig'); return $template; } elseif (file_exists($matchDir . $file)) { Logger::info('HTML: ' . $file); $template = new HtmlTemplate(); $template->setTemplateDir($matchDir); $template->setTemplateFile($file); return $template; } }