Exemplo n.º 1
0
 /**
  * returns the compiled template file name
  *
  * @param Core      $dwoo     the dwoo instance that requests it
  * @param ICompiler $compiler the compiler that must be used
  *
  * @return string
  */
 public function getCompiledTemplate(Core $dwoo, ICompiler $compiler = null)
 {
     $compiledFile = $this->getCompiledFilename($dwoo);
     if ($this->debug !== true && $this->compilationEnforced !== true && isset(self::$cache['compiled'][$this->compileId]) === true) {
         // already checked, return compiled file
     } elseif ($this->debug !== true && $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('Compiler') === false) {
                     include_once Core::DWOO_DIRECTORY . DIRECTORY_SEPARATOR . 'Compiler.php';
                 }
                 $compiler = Compiler::compilerFactory();
             } else {
                 $compiler = call_user_func($compiler);
             }
         }
         $compiler->debug = $this->debug;
         $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);
         }
         self::$cache['compiled'][$this->compileId] = true;
     }
     return $compiledFile;
 }
Exemplo n.º 2
0
 /**
  * Return the Dwoo compiler object
  *
  * @return ICompiler
  */
 public function getCompiler()
 {
     if (null === $this->_compiler) {
         $this->_compiler = Compiler::compilerFactory();
     }
     return $this->_compiler;
 }