Phrozn\Site\View\Factory::setInputRootDir PHP Method

setInputRootDir() public method

Set input root dir
public setInputRootDir ( string $path ) : Factory
$path string Input root directory
return Factory
    public function setInputRootDir($path)
    {
        $this->inputRootDir = $path;
        return $this;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Create list of views to be created
  *
  * @return \Phrozn\Site
  */
 protected function buildQueue()
 {
     // guess the base path with Phrozn project
     $projectDir = $this->getProjectDir();
     $outputDir = $this->getOutputDir();
     $config = $this->getSiteConfig();
     // configure skip files options
     $skipToken = '-!SKIP!-';
     $folders = array('entries', 'styles', 'scripts');
     foreach ($folders as $folder) {
         $dir = new \RecursiveDirectoryIterator($projectDir . '/' . $folder);
         $it = new \RecursiveIteratorIterator($dir, \RecursiveIteratorIterator::SELF_FIRST);
         foreach ($it as $item) {
             $baseName = $item->getBaseName();
             if (isset($config['skip'])) {
                 $baseName = preg_replace($config['skip'], array_fill(0, count($config['skip']), $skipToken), $baseName);
                 if (strpos($baseName, $skipToken) !== false) {
                     continue;
                 }
             }
             if ($item->isFile()) {
                 try {
                     $factory = new View\Factory($item->getRealPath());
                     $factory->setInputRootDir($projectDir);
                     $view = $factory->create();
                     $view->setSiteConfig($this->getSiteConfig())->setOutputDir($outputDir);
                     $this->views[] = $view;
                 } catch (\Exception $e) {
                     $this->getOutputter()->stderr(str_replace($projectDir, '', $item->getRealPath()) . ': ' . $e->getMessage());
                 }
             }
         }
     }
     return $this;
 }