public function init() { // default path to runtime if (!Alias::existsAlias('runtime')) { Alias::setAlias('runtime', dirname(__DIR__) . '/runtime'); } $this->twig = new \Twig_Environment(null, array_merge(['cache' => Alias::getAlias($this->cachePath)], $this->options)); //$this->twig->setBaseTemplateClass('rock\template\twig\Template'); // Adding custom globals (objects or static classes) if (!empty($this->globals)) { $this->addGlobals($this->globals); } // Adding custom functions if (!empty($this->functions)) { $this->addFunctions($this->functions); } // Adding custom filters if (!empty($this->filters)) { $this->addFilters($this->filters); } $this->addExtensions([new Extension($this->uses)]); // Adding custom extensions if (!empty($this->extensions)) { $this->addExtensions($this->extensions); } //$this->twig->addGlobal('app', \rock\Rock::$app); // Change lexer syntax (must be set after other settings) if (!empty($this->lexerOptions)) { $this->addLexerOptions($this->lexerOptions); } }
public function init() { // default path to view if (!Alias::existsAlias('template.views')) { Alias::setAlias('template.views', dirname(__DIR__) . '/views'); } $this->request = Instance::ensure($this->request, '\\rock\\request\\Request'); $this->cache = Instance::ensure($this->cache, null, [], false); foreach ($this->chroots as &$chroot) { $chroot = Alias::getAlias($chroot); } $this->snippets = array_merge($this->defaultSnippets(), $this->snippets); $this->filters = array_merge($this->defaultFilters(), $this->filters); }