diff --git a/src/Step/Data/Load.php b/src/Step/Data/Load.php index 0451c9c05..009b67baa 100644 --- a/src/Step/Data/Load.php +++ b/src/Step/Data/Load.php @@ -41,7 +41,7 @@ public function getName(): string */ public function init(array $options): void { - if (is_dir($this->builder->getConfig()->getDataPath()) && (bool) $this->config->get('data.load')) { + if (is_dir($this->config->getDataPath()) && (bool) $this->config->get('data.load')) { $this->canProcess = true; } } @@ -53,8 +53,8 @@ public function process(): void { $files = Finder::create() ->files() - ->in($this->builder->getConfig()->getDataPath()) - ->name('/\.(' . implode('|', (array) $this->builder->getConfig()->get('data.ext')) . ')$/') + ->in($this->config->getDataPath()) + ->name('/\.(' . implode('|', (array) $this->config->get('data.ext')) . ')$/') ->sortByName(true); $total = count($files); @@ -103,7 +103,7 @@ function ($severity, $message, $file, $line) { $basename = $file->getBasename('.' . $file->getExtension()); $subpath = \Cecil\Util\File::getFS()->makePathRelative( $file->getPath(), - $this->builder->getConfig()->getDataPath() + $this->config->getDataPath() ); $subpath = trim($subpath, './'); $array = []; diff --git a/src/Step/Pages/Convert.php b/src/Step/Pages/Convert.php index 3be562952..922bb3112 100644 --- a/src/Step/Pages/Convert.php +++ b/src/Step/Pages/Convert.php @@ -45,7 +45,7 @@ public function init(array $options): void { parent::init($options); - if (is_dir($this->builder->getConfig()->getPagesPath())) { + if (is_dir($this->config->getPagesPath())) { $this->canProcess = true; } } @@ -77,7 +77,7 @@ public function process(): void $this->builder->getPages()->remove($page->getId()); continue; } catch (\Exception $e) { - $this->builder->getLogger()->error(\sprintf('Unable to convert "%s": %s', Util::joinPath(Util\File::getFS()->makePathRelative($page->getFilePath(), $this->builder->getConfig()->getPagesPath())), $e->getMessage())); + $this->builder->getLogger()->error(\sprintf('Unable to convert "%s": %s', Util::joinPath(Util\File::getFS()->makePathRelative($page->getFilePath(), $this->config->getPagesPath())), $e->getMessage())); $this->builder->getPages()->remove($page->getId()); continue; } diff --git a/src/Step/Pages/Create.php b/src/Step/Pages/Create.php index df4baf2f6..6b63932d7 100644 --- a/src/Step/Pages/Create.php +++ b/src/Step/Pages/Create.php @@ -37,7 +37,7 @@ public function init(array $options): void { $this->builder->setPages(new PagesCollection('all-pages')); - if (is_dir($this->builder->getConfig()->getPagesPath())) { + if (is_dir($this->config->getPagesPath())) { $this->canProcess = true; } } diff --git a/src/Step/Pages/Generate.php b/src/Step/Pages/Generate.php index d6534d4bc..8c89d472d 100644 --- a/src/Step/Pages/Generate.php +++ b/src/Step/Pages/Generate.php @@ -35,7 +35,7 @@ public function getName(): string */ public function init(array $options): void { - if (count((array) $this->builder->getConfig()->get('generators')) > 0) { + if (count((array) $this->config->get('generators')) > 0) { $this->canProcess = true; } } @@ -49,7 +49,7 @@ public function process(): void Util::autoload($this->builder, 'generators'); - $generators = (array) $this->builder->getConfig()->get('generators'); + $generators = (array) $this->config->get('generators'); array_walk($generators, function ($generator, $priority) use ($generatorManager) { if (!class_exists($generator)) { $message = \sprintf('Unable to load generator "%s".', $generator); diff --git a/src/Step/Pages/Load.php b/src/Step/Pages/Load.php index dc29d8e91..d7d1d469a 100644 --- a/src/Step/Pages/Load.php +++ b/src/Step/Pages/Load.php @@ -40,12 +40,12 @@ public function getName(): string public function init(array $options): void { // legacy support - if (is_dir(Util::joinFile($this->builder->getConfig()->getSourceDir(), 'content'))) { + if (is_dir(Util::joinFile($this->config->getSourceDir(), 'content'))) { $this->builder->getLogger()->alert('"content" directory is deprecated, please rename it to "pages"'); } - if (!is_dir($this->builder->getConfig()->getPagesPath())) { - throw new RuntimeException(\sprintf('Pages path "%s" not found.', $this->builder->getConfig()->getPagesPath())); + if (!is_dir($this->config->getPagesPath())) { + throw new RuntimeException(\sprintf('Pages path "%s" not found.', $this->config->getPagesPath())); } $this->page = $options['page']; @@ -57,39 +57,39 @@ public function init(array $options): void */ public function process(): void { - $namePattern = '/\.(' . implode('|', (array) $this->builder->getConfig()->get('pages.ext')) . ')$/'; + $namePattern = '/\.(' . implode('|', (array) $this->config->get('pages.ext')) . ')$/'; $content = Finder::create() ->files() - ->in($this->builder->getConfig()->getPagesPath()) + ->in($this->config->getPagesPath()) ->sortByName(true); // load only one page? if ($this->page) { // is the page path starts with the `pages.dir` configuration option? // (i.e.: `pages/...`, `/pages/...`, `./pages/...`) $pagePathAsArray = explode(DIRECTORY_SEPARATOR, $this->page); - if ($pagePathAsArray[0] == (string) $this->builder->getConfig()->get('pages.dir')) { + if ($pagePathAsArray[0] == (string) $this->config->get('pages.dir')) { unset($pagePathAsArray[0]); $this->page = implode(DIRECTORY_SEPARATOR, $pagePathAsArray); } - if ($pagePathAsArray[0] == '.' && $pagePathAsArray[1] == (string) $this->builder->getConfig()->get('pages.dir')) { + if ($pagePathAsArray[0] == '.' && $pagePathAsArray[1] == (string) $this->config->get('pages.dir')) { unset($pagePathAsArray[0]); unset($pagePathAsArray[1]); $this->page = implode(DIRECTORY_SEPARATOR, $pagePathAsArray); } - if (!util\File::getFS()->exists(Util::joinFile($this->builder->getConfig()->getPagesPath(), $this->page))) { + if (!util\File::getFS()->exists(Util::joinFile($this->config->getPagesPath(), $this->page))) { $this->builder->getLogger()->error(sprintf('File "%s" doesn\'t exist.', $this->page)); } $content->path('.')->path(dirname($this->page)); - $content->name('/index\.(' . implode('|', (array) $this->builder->getConfig()->get('pages.ext')) . ')$/'); + $content->name('/index\.(' . implode('|', (array) $this->config->get('pages.ext')) . ')$/'); $namePattern = basename($this->page); } $content->name($namePattern); - if (is_array($this->builder->getConfig()->get('pages.exclude'))) { - $content->exclude($this->builder->getConfig()->get('pages.exclude')); - $content->notPath($this->builder->getConfig()->get('pages.exclude')); - $content->notName($this->builder->getConfig()->get('pages.exclude')); + if (is_array($this->config->get('pages.exclude'))) { + $content->exclude($this->config->get('pages.exclude')); + $content->notPath($this->config->get('pages.exclude')); + $content->notName($this->config->get('pages.exclude')); } - if (file_exists(Util::joinFile($this->builder->getConfig()->getPagesPath(), '.gitignore'))) { + if (file_exists(Util::joinFile($this->config->getPagesPath(), '.gitignore'))) { $content->ignoreVCSIgnored(true); } $this->builder->setPagesFiles($content); diff --git a/src/Step/PostProcess/AbstractPostProcess.php b/src/Step/PostProcess/AbstractPostProcess.php index 0b008fe98..7108563a2 100644 --- a/src/Step/PostProcess/AbstractPostProcess.php +++ b/src/Step/PostProcess/AbstractPostProcess.php @@ -38,10 +38,10 @@ public function init(array $options): void if ($options['dry-run']) { return; } - if (false === $this->builder->getConfig()->get(\sprintf('postprocess.%s.enabled', $this->type))) { + if (false === $this->config->get(\sprintf('postprocess.%s.enabled', $this->type))) { return; } - if (true === $this->builder->getConfig()->get('postprocess.enabled')) { + if (true === $this->config->get('postprocess.enabled')) { $this->canProcess = true; } } @@ -55,14 +55,14 @@ public function process(): void { $this->setProcessor(); - $extensions = (array) $this->builder->getConfig()->get(\sprintf('postprocess.%s.ext', $this->type)); + $extensions = (array) $this->config->get(\sprintf('postprocess.%s.ext', $this->type)); if (empty($extensions)) { throw new RuntimeException(\sprintf('The config key "postprocess.%s.ext" is empty', $this->type)); } $files = Finder::create() ->files() - ->in($this->builder->getConfig()->getOutputPath()) + ->in($this->config->getOutputPath()) ->name('/\.(' . implode('|', $extensions) . ')$/') ->notName('/\.min\.(' . implode('|', $extensions) . ')$/') ->sortByName(true); diff --git a/src/Step/StaticFiles/Load.php b/src/Step/StaticFiles/Load.php index f82e83d7f..e8106e9c5 100644 --- a/src/Step/StaticFiles/Load.php +++ b/src/Step/StaticFiles/Load.php @@ -36,7 +36,7 @@ public function getName(): string */ public function init(array $options): void { - if (is_dir($this->builder->getConfig()->getStaticPath()) && (bool) $this->config->get('static.load')) { + if (is_dir($this->config->getStaticPath()) && (bool) $this->config->get('static.load')) { $this->canProcess = true; } } diff --git a/src/Step/Taxonomies/Create.php b/src/Step/Taxonomies/Create.php index 3b3fdba32..68f0504e2 100644 --- a/src/Step/Taxonomies/Create.php +++ b/src/Step/Taxonomies/Create.php @@ -41,7 +41,7 @@ public function getName(): string */ public function init(array $options): void { - if (is_dir($this->builder->getConfig()->getPagesPath()) && $this->hasTaxonomies()) { + if (is_dir($this->config->getPagesPath()) && $this->hasTaxonomies()) { $this->canProcess = true; } }