Phrozn\Site\Base::buildQueue PHP Method

buildQueue() protected method

Create list of views to be created
protected buildQueue ( ) : Phrozn\Site
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;
    }