/** * @expectedException \Webiny\Component\TemplateEngine\TemplateEngineException * @expectedExceptionMessage Unable to read driver configuration */ public function testGetInstanceException() { TemplateEngineLoader::getInstance('Fake'); }
/** * Returns template engine instance, based on current configuration. * If a template engine is not defined, a default template engine instance will be created. * * @return \Webiny\Component\TemplateEngine\Bridge\TemplateEngineInterface * @throws \Exception * @throws \Webiny\Component\StdLib\Exception\Exception * @throws \Webiny\Component\TemplateEngine\TemplateEngineException */ private function getTemplateEngineInstance() { $teConfig = $this->getComponentConfig('TemplateEngine', 'Engines', false); // fallback to default template engine if (!$teConfig) { $defaultTemplateEngineConfig = ['Engines' => ['Smarty' => ['ForceCompile' => false, 'CacheDir' => $this->getAbsolutePath() . 'App/Cache/Smarty/Cache', 'CompileDir' => $this->getAbsolutePath() . 'App/Cache/Smarty/Compile', 'TemplateDir' => $this->getAbsolutePath() . 'App/Layouts', 'AutoEscapeOutput' => false]]]; TemplateEngine::setConfig(new ConfigObject($defaultTemplateEngineConfig)); return TemplateEngineLoader::getInstance('Smarty'); } $teConfig = $this->getComponentConfig('TemplateEngine', 'Engines')->toArray(); reset($teConfig); $teName = key($teConfig); return TemplateEngineLoader::getInstance($teName); }