diff --git a/system/src/Grav/Common/Page/Interfaces/PageLegacyInterface.php b/system/src/Grav/Common/Page/Interfaces/PageLegacyInterface.php index 35d6d2180..1f84b951b 100644 --- a/system/src/Grav/Common/Page/Interfaces/PageLegacyInterface.php +++ b/system/src/Grav/Common/Page/Interfaces/PageLegacyInterface.php @@ -367,7 +367,7 @@ interface PageLegacyInterface /** * Returns children of this page. * - * @return \Grav\Common\Page\Collection + * @return Collection */ public function children(); diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index f467d2cc5..773f1a904 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -69,7 +69,7 @@ class Page implements PageInterface protected $slug; /** @var string */ protected $route; - /** @var string */ + /** @var string|null */ protected $raw_route; /** @var string */ protected $url; @@ -89,15 +89,15 @@ class Page implements PageInterface protected $frontmatter; /** @var string */ protected $language; - /** @var string */ + /** @var string|null */ protected $content; /** @var array */ protected $content_meta; - /** @var string */ - protected $summry; + /** @var string|null */ + protected $summary; /** @var string */ protected $raw_content; - /** @var array */ + /** @var array|null */ protected $metadata; /** @var string */ protected $title; @@ -115,13 +115,13 @@ class Page implements PageInterface protected $order_by; /** @var string */ protected $order_dir; - /** @var array */ + /** @var array|string|null */ protected $order_manual; /** @var bool */ protected $modular_twig; /** @var array */ protected $process; - /** @var int */ + /** @var int|null */ protected $summary_size; /** @var bool */ protected $markdown_extra; diff --git a/system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php b/system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php index c49141ead..bb261f8d9 100644 --- a/system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php +++ b/system/src/Grav/Framework/Flex/Pages/Traits/PageLegacyTrait.php @@ -21,6 +21,7 @@ use Grav\Framework\Cache\CacheInterface; use Grav\Framework\File\Formatter\MarkdownFormatter; use Grav\Framework\File\Formatter\YamlFormatter; use Grav\Framework\Flex\FlexDirectory; +use Grav\Framework\Flex\Interfaces\FlexCollectionInterface; use Grav\Framework\Flex\Interfaces\FlexIndexInterface; use Grav\Framework\Flex\Interfaces\FlexObjectInterface; use Grav\Framework\Flex\Pages\FlexPageIndex; @@ -867,8 +868,12 @@ trait PageLegacyTrait public function isFirst(): bool { $parent = $this->parent(); + $children = $parent ? $parent->children() : null; + if ($children instanceof FlexCollectionInterface) { + $children = $children->withKeyField(); + } - return $parent ? $parent->children()->withKeyField()->isFirst($this->getKey()) : true; + return $children instanceof PageCollectionInterface ? $children->isFirst($this->getKey()) : true; } /** @@ -879,8 +884,12 @@ trait PageLegacyTrait public function isLast(): bool { $parent = $this->parent(); + $children = $parent ? $parent->children() : null; + if ($children instanceof FlexCollectionInterface) { + $children = $children->withKeyField(); + } - return $parent ? $parent->children()->withKeyField()->isLast($this->getKey()) : true; + return $children instanceof PageCollectionInterface ? $children->isLast($this->getKey()) : true; } /** @@ -913,8 +922,12 @@ trait PageLegacyTrait public function adjacentSibling($direction = 1) { $parent = $this->parent(); + $children = $parent ? $parent->children() : null; + if ($children instanceof FlexCollectionInterface) { + $children = $children->withKeyField(); + } - return $parent ? $parent->children()->withKeyField()->adjacentSibling($this->getKey(), $direction) : false; + return $children instanceof PageCollectionInterface ? $children->adjacentSibling($this->getKey(), $direction) : false; } /**