/** * Loads the Twig instance and registers the autoloader. */ public function configure() { parent::configure(); $this->configuration = $this->context->getConfiguration(); // template name $template = sfConfig::get('sf_template'); $templateDir = sfConfig::get('sf_template_dir') . '/' . $template; if (!file_exists($templateDir)) { throw new sfException(__METHOD__ . ": Couldn't find template " . $template); } // decorator template path $layoutTemplateDir = $templateDir . '/global'; if (is_readable($layoutTemplateDir . '/' . $this->getDecoratorTemplate())) { $this->setDecoratorDirectory($layoutTemplateDir); } // module template path $moduleTemplateDir = $templateDir . '/modules/' . $this->moduleName; if (is_readable($moduleTemplateDir . '/' . $this->getTemplate())) { $this->setDirectory($moduleTemplateDir); } // init twig engine // empty array becuase it changes based on the rendering context $this->loader = new Twig_Loader_Filesystem(array()); $this->twig = new sfTwigEnvironment($this->loader, array('cache' => sfConfig::get('sf_template_cache_dir') . '/' . $template, 'debug' => sfConfig::get('sf_debug', false), 'sf_context' => $this->context)); if ($this->twig->isDebug()) { $this->twig->setAutoReload(true); } $this->loadExtensions(); }
/** * Loads the Twig instance and registers the autoloader. * * @return void */ public function configure() { parent::configure(); $this->configuration = $this->context->getConfiguration(); //Empty array becuase it changes based on the rendering context $this->loader = new Twig_Loader_Filesystem(array()); $this->twig = new Twig_Environment($this->loader, array('cache' => sfConfig::get('sf_template_cache_dir'), 'debug' => sfConfig::get('sf_debug', false))); if ($this->twig->isDebug()) { $this->twig->setCache(null); $this->twig->setAutoReload(true); } $this->loadExtensions(); }