Upgrade to 3.5.2

This commit is contained in:
Bastian Allgeier
2021-02-09 16:55:18 +01:00
parent 99c36fa137
commit b507926ad1
53 changed files with 350 additions and 355 deletions

View File

@@ -23,12 +23,19 @@ use Kirby\Exception\InvalidArgumentException;
class Pages extends Collection
{
/**
* Cache for the index
* Cache for the index only listed and unlisted pages
*
* @var \Kirby\Cms\Pages|null
*/
protected $index = null;
/**
* Cache for the index all statuses also including drafts
*
* @var \Kirby\Cms\Pages|null
*/
protected $indexWithDrafts = null;
/**
* All registered pages methods
*
@@ -331,24 +338,31 @@ class Pages extends Collection
*/
public function index(bool $drafts = false)
{
if (is_a($this->index, 'Kirby\Cms\Pages') === true) {
return $this->index;
// get object property by cache mode
$index = $drafts === true ? $this->indexWithDrafts : $this->index;
if (is_a($index, 'Kirby\Cms\Pages') === true) {
return $index;
}
$this->index = new Pages([], $this->parent);
$index = new Pages([], $this->parent);
foreach ($this->data as $pageKey => $page) {
$this->index->data[$pageKey] = $page;
$index = $page->index($drafts);
$index->data[$pageKey] = $page;
$pageIndex = $page->index($drafts);
if ($index) {
foreach ($index as $childKey => $child) {
$this->index->data[$childKey] = $child;
if ($pageIndex) {
foreach ($pageIndex as $childKey => $child) {
$index->data[$childKey] = $child;
}
}
}
return $this->index;
if ($drafts === true) {
return $this->indexWithDrafts = $index;
}
return $this->index = $index;
}
/**