Example #1
0
 /**
  * Build views in order to parse php files
  *
  * @param Array $viewPaths
  * @param String $domain
  *
  * @return Boolean status
  */
 public function compileViews(array $viewPaths, $domain)
 {
     // Check the output directory
     $targetDir = $this->storagePath . DIRECTORY_SEPARATOR . $this->storageContainer;
     if (!file_exists($targetDir)) {
         $this->createDirectory($targetDir);
     }
     // Domain separation
     $domainDir = $targetDir . DIRECTORY_SEPARATOR . $domain;
     $this->clearDirectory($domainDir);
     $this->createDirectory($domainDir);
     foreach ($viewPaths as $path) {
         $path = $this->basePath . DIRECTORY_SEPARATOR . $path;
         $fs = new \Illuminate\Filesystem\Filesystem($path);
         $files = $fs->allFiles(realpath($path));
         $compiler = new \Illuminate\View\Compilers\BladeCompiler($fs, $domainDir);
         foreach ($files as $file) {
             $filePath = $file->getRealPath();
             $compiler->setPath($filePath);
             $contents = $compiler->compileString($fs->get($filePath));
             $compiledPath = $compiler->getCompiledPath($compiler->getPath());
             $fs->put($compiledPath . '.php', $contents);
         }
     }
     return true;
 }