public static function compilerFactory() { if (!isset(static::$_instance_compiler)) { static::$_instance_compiler = \Dwoo_Compiler::compilerFactory(); } return static::$_instance_compiler; }
/** * Return the Dwoo compiler object * * @return Dwoo_Data */ public function getCompiler() { if (null === $this->_compiler) { $this->_compiler = Dwoo_Compiler::compilerFactory(); } return $this->_compiler; }
/** * provides a custom compiler to the dwoo renderer with optional settings * you can set in the agavi output_types.xml config file * * @return Dwoo_Compiler */ public function compilerFactory() { if (class_exists('Dwoo_Compiler', false) === false) { include DWOO_DIRECTORY . 'Dwoo/Compiler.php'; } $compiler = Dwoo_Compiler::compilerFactory(); $compiler->setAutoEscape((bool) $this->getParameter('auto_escape', false)); return $compiler; }
/** * returns the compiled template file name * * @param Dwoo $dwoo the dwoo instance that requests it * @param Dwoo_ICompiler $compiler the compiler that must be used * @return string */ public function getCompiledTemplate(Dwoo $dwoo, Dwoo_ICompiler $compiler = null) { $compiledFile = $this->getCompiledFilename($dwoo); if ($this->compilationEnforced !== true && isset(self::$cache['compiled'][$this->compileId]) === true) { // already checked, return compiled file } elseif ($this->compilationEnforced !== true && $this->isValidCompiledFile($compiledFile)) { // template is compiled self::$cache['compiled'][$this->compileId] = true; } else { // compiles the template $this->compilationEnforced = false; if ($compiler === null) { $compiler = $dwoo->getDefaultCompilerFactory($this->getResourceName()); if ($compiler === null || $compiler === array('Dwoo_Compiler', 'compilerFactory')) { if (class_exists('Dwoo_Compiler', false) === false) { include DWOO_DIRECTORY . 'Dwoo/Compiler.php'; } $compiler = Dwoo_Compiler::compilerFactory(); } else { $compiler = call_user_func($compiler); } } $this->compiler = $compiler; $compiler->setCustomPlugins($dwoo->getCustomPlugins()); $compiler->setSecurityPolicy($dwoo->getSecurityPolicy()); $this->makeDirectory(dirname($compiledFile)); file_put_contents($compiledFile, $compiler->compile($dwoo, $this)); if ($this->chmod !== null) { chmod($compiledFile, $this->chmod); } self::$cache['compiled'][$this->compileId] = true; } return $compiledFile; }
/** * returns the compiled template file name * * @param Dwoo_Core $dwoo the dwoo instance that requests it * @param Dwoo_ICompiler $compiler the compiler that must be used * @return string */ public function getCompiledTemplate(Dwoo_Core $dwoo, Dwoo_ICompiler $compiler = null) { $compiledFile = $this->getCompiledFilename($dwoo); if ($this->compilationEnforced !== true && isset(self::$cache['compiled'][$this->compileId]) === true) { // already checked, return compiled file } elseif ($this->compilationEnforced !== true && $this->isValidCompiledFile($compiledFile)) { // template is compiled self::$cache['compiled'][$this->compileId] = true; } else { // compiles the template $this->compilationEnforced = false; if ($compiler === null) { $compiler = $dwoo->getDefaultCompilerFactory($this->getResourceName()); if ($compiler === null || $compiler === array('Dwoo_Compiler', 'compilerFactory')) { $compiler = Dwoo_Compiler::compilerFactory(); } else { $compiler = call_user_func($compiler); } } $this->compiler = $compiler; $compiler->setCustomPlugins($dwoo->getCustomPlugins()); $compiler->setSecurityPolicy($dwoo->getSecurityPolicy()); $this->makeDirectory(dirname($compiledFile), $dwoo->getCompileDir()); file_put_contents($compiledFile, $compiler->compile($dwoo, $this)); if ($this->chmod !== null) { chmod($compiledFile, $this->chmod); } if (extension_loaded('Zend OPcache')) { opcache_invalidate($compiledFile); } elseif (extension_loaded('apc')) { apc_compile_file($compiledFile); } self::$cache['compiled'][$this->compileId] = true; } return $compiledFile; }
/** * returns a compiler object when one is required * * @return Dwoo_Compiler */ public function compilerFactory() { $compiler = Dwoo_Compiler::compilerFactory(); $compiler->setDelimiters($this->left_delimiter, $this->right_delimiter); $compiler->setAutoEscape(true); return $compiler; }