Ejemplo n.º 1
0
 public function testRelativeDirFails()
 {
     $obj = new SmartyTemplate();
     $obj->setCacheDir('/tmp');
     $obj->setProjectTemplateDir(SYNERGY_ROOT_DIR . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'templates');
     $obj->setTemplateFile('index.html.tpl');
     $this->setExpectedException('Synergy\\Exception\\SynergyException');
     $obj->init();
 }
Ejemplo n.º 2
0
 /**
  * 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;
     }
 }