Added page blueprints to YamlLinter

This commit is contained in:
Andy Miller
2019-05-12 11:24:50 -06:00
parent e9bbd1e0b0
commit 2a49a2ba7c
3 changed files with 29 additions and 1 deletions

View File

@@ -1,3 +1,9 @@
# v1.6.10
## mm/dd/2019
1. [](#improved)
* Added **page blueprints** to `YamlLinter` CLI and Admin reports
# v1.6.9 # v1.6.9
## 05/09/2019 ## 05/09/2019

View File

@@ -20,7 +20,8 @@ class YamlLinter
{ {
$errors = static::lintConfig(); $errors = static::lintConfig();
$errors = $errors + static::lintPages(); $errors = $errors + static::lintPages();
$errors = $errors + static::lintBlueprints();
return $errors; return $errors;
} }
@@ -34,6 +35,18 @@ class YamlLinter
return static::recurseFolder('config://'); return static::recurseFolder('config://');
} }
public static function lintBlueprints()
{
/** @var UniformResourceLocator $locator */
$locator = Grav::instance()['locator'];
$current_theme = Grav::instance()['config']->get('system.pages.theme');
$theme_path = 'themes://' . $current_theme . '/blueprints';
$locator->addPath('blueprints', '', [$theme_path]);
return static::recurseFolder('blueprints://');
}
public static function recurseFolder($path, $extensions = 'md|yaml') public static function recurseFolder($path, $extensions = 'md|yaml')
{ {
$lint_errors = []; $lint_errors = [];

View File

@@ -61,6 +61,15 @@ class YamlLinterCommand extends ConsoleCommand
$this->displayErrors($errors, $io); $this->displayErrors($errors, $io);
} }
$io->section('Page Blueprints');
$errors = YamlLinter::lintBlueprints();
if (empty($errors)) {
$io->success('No YAML Linting issues with blueprints');
} else {
$this->displayErrors($errors, $io);
}
} }
protected function displayErrors($errors, $io) protected function displayErrors($errors, $io)