Esempio n. 1
0
 /**
  * Compiles the file without executing directives.
  */
 protected function compileFileBody($file)
 {
     $tempFilePath = $this->tempFolder() . '/' . $file->subPathsPath() . $file->name() . '-body' . ($this->config['compress'] ? '-c' : '') . '.' . $file->type();
     $dir = pathinfo($tempFilePath, PATHINFO_DIRNAME);
     if (!is_dir($dir)) {
         mkdir($dir, 0775, true);
     }
     $recompile = true;
     if (is_file($tempFilePath)) {
         $tempFileMTime = filemtime($tempFilePath);
         if (filemtime($file->originalFilePath()) <= $tempFileMTime) {
             $recompile = false;
         }
     }
     if ($recompile) {
         $processor = new Processor\Processor($this);
         $compiledFile = $processor->compileFile($file);
         $compiledFile = $this->compressCompiledFile($file->type(), $compiledFile);
         # Cache compiled file.
         file_put_contents($tempFilePath, $compiledFile);
     }
     return ['file' => $file, 'tempFilePath' => $tempFilePath];
 }