Fixed page initialization in CLI

This commit is contained in:
Matias Griese
2020-02-11 20:53:02 +02:00
parent f81503dd70
commit 95442ef0b5
3 changed files with 15 additions and 7 deletions

View File

@@ -8,7 +8,8 @@
* Added `ConsoleCommand::initializeThemes()`method to properly set up current theme to be used from CLI
* Added `ConsoleCommand::initializePages()` method to properly set up pages to be used from CLI
1. [](#bugfix)
* Fixed `bin/plugin` CLI calling `$themes->init()` way too early
* Fixed `bin/plugin` CLI calling `$themes->init()` way too early (removed it, use above methods instead)
* Fixed call to `$grav['page']` crashing CLI
* Fixed encoding problems when PHP INI setting `default_charset` is not `utf-8` [#2154](https://github.com/getgrav/grav/issues/2154)
# v1.6.20

View File

@@ -26,6 +26,19 @@ class PagesServiceProvider implements ServiceProviderInterface
return new Pages($c);
};
if (GRAV_CLI) {
$container['page'] = static function ($c) {
$path = $c['locator']->findResource('system://pages/notfound.md');
$page = new Page();
$page->init(new \SplFileInfo($path));
$page->routable(false);
return $page;
};
return;
}
$container['page'] = function ($c) {
/** @var Grav $c */

View File

@@ -171,12 +171,6 @@ class ConsoleCommand extends Command
$pages = $grav['pages'];
$pages->init();
$grav->fireEvent('onPagesInitialized', new Event(['pages' => $pages]));
if (!isset($grav['page'])) {
$page = new Page();
$page->routable(false);
$page->title('404 Not Found');
$grav['page'] = $page;
}
}
return $this;