コード例 #1
0
ファイル: TemplateEngine.php プロジェクト: Webiny/Framework
 /**
  * Get the name of bridge library which will be used as the driver.
  *
  * @param string $engineName Name of the template engine for which you wish to get the
  *
  * @return string
  */
 private static function getLibrary($engineName)
 {
     $bridges = \Webiny\Component\TemplateEngine\TemplateEngine::getConfig()->get('Bridges', false);
     if (!$bridges) {
         if (!isset(self::$library[$engineName])) {
             return false;
         }
         return self::$library[$engineName];
     }
     return $bridges->get($engineName, false);
 }
コード例 #2
0
 public function setUp()
 {
     TemplateEngine::setConfig(__DIR__ . '/ExampleConfig.yaml');
 }
コード例 #3
0
 public function testGetConfig()
 {
     $config = TemplateEngine::getConfig();
     $this->assertSame(__DIR__ . '/temp/cache', $config->get('Engines.Smarty.CacheDir'));
 }
コード例 #4
0
 public function setUp()
 {
     \Webiny\Component\TemplateEngine\TemplateEngine::setConfig(__DIR__ . '/../ExampleConfig.yaml');
 }
コード例 #5
0
ファイル: SmartyTest.php プロジェクト: Nkelliny/Framework
 public function setUp()
 {
     // make sure we unregister the class loader map, can cause a conflict with the composer
     ClassLoader::getInstance()->unregisterMap('Smarty_');
     TemplateEngine::setConfig(__DIR__ . '/../../ExampleConfig.yaml');
 }
コード例 #6
0
ファイル: Application.php プロジェクト: Webiny/Framework
 /**
  * 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);
 }