mirror of
https://github.com/getgrav/grav.git
synced 2025-02-20 19:56:53 +01:00
Added support for not instantiating pages, useful to speed up tasks
This commit is contained in:
parent
f30f6485ba
commit
52cf554ea2
|
|
@ -5,6 +5,7 @@
|
|||
* Added experimental support for `Flex Pages` (**Flex Objects** plugin required)
|
||||
1. [](#improved)
|
||||
* Improved `bin/grav yamllinter` CLI command by adding an option to find YAML Linting issues from the whole site or custom folder
|
||||
* Added support for not instantiating pages, useful to speed up tasks
|
||||
1. [](#bugfix)
|
||||
* Fixed `$page->summary()` always striping HTML tags if the summary was set by `$page->setSummary()`
|
||||
* Grav 1.7: Fixed enabling PHP Debug Bar causes fatal error in Gantry [#2634](https://github.com/getgrav/grav/issues/2634)
|
||||
|
|
|
|||
|
|
@ -55,6 +55,9 @@ class Pages
|
|||
/** @var Blueprints */
|
||||
protected $blueprints;
|
||||
|
||||
/** @var bool */
|
||||
protected $enable_pages = true;
|
||||
|
||||
/** @var int */
|
||||
protected $last_modified;
|
||||
|
||||
|
|
@ -91,6 +94,14 @@ class Pages
|
|||
$this->grav = $c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method used in admin to disable pages from being loaded.
|
||||
*/
|
||||
public function disablePages(): void
|
||||
{
|
||||
$this->enable_pages = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or set base path for the pages.
|
||||
*
|
||||
|
|
@ -830,7 +841,7 @@ class Pages
|
|||
/** @var UniformResourceLocator $locator */
|
||||
$locator = $this->grav['locator'];
|
||||
|
||||
return $this->instances[rtrim($locator->findResource('page://'), DS)];
|
||||
return $this->instances[rtrim($locator->findResource('page://'), '/')];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1194,8 +1205,15 @@ class Pages
|
|||
*
|
||||
* @internal
|
||||
*/
|
||||
protected function buildPages()
|
||||
protected function buildPages(): void
|
||||
{
|
||||
if ($this->enable_pages === false) {
|
||||
$page = $this->buildRootPage();
|
||||
$this->instances[$page->path()] = $page;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var Config $config */
|
||||
$config = $this->grav['config'];
|
||||
|
||||
|
|
@ -1272,6 +1290,29 @@ class Pages
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
protected function buildRootPage()
|
||||
{
|
||||
$grav = Grav::instance();
|
||||
|
||||
/** @var UniformResourceLocator $locator */
|
||||
$locator = $grav['locator'];
|
||||
|
||||
/** @var Config $config */
|
||||
$config = $grav['config'];
|
||||
|
||||
$page = new Page();
|
||||
$page->path($locator->findResource('page://'));
|
||||
$page->orderDir($config->get('system.pages.order.dir'));
|
||||
$page->orderBy($config->get('system.pages.order.by'));
|
||||
$page->modified(0);
|
||||
$page->routable(false);
|
||||
$page->template('default');
|
||||
$page->extension('.md');
|
||||
|
||||
return $page;
|
||||
}
|
||||
|
||||
protected function buildRegularPages()
|
||||
{
|
||||
/** @var Config $config */
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user