From c57a29c23f36e5e22228c73e80d3d6f4be19e48e Mon Sep 17 00:00:00 2001 From: Karmalakas Date: Tue, 6 Jul 2021 21:14:06 +0300 Subject: [PATCH] Add `setCurrent()` method to Page Collection #531 --- system/src/Grav/Common/Page/Collection.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/system/src/Grav/Common/Page/Collection.php b/system/src/Grav/Common/Page/Collection.php index 139a58bc5..a37f46a27 100644 --- a/system/src/Grav/Common/Page/Collection.php +++ b/system/src/Grav/Common/Page/Collection.php @@ -145,6 +145,18 @@ class Collection extends Iterator implements PageCollectionInterface return $this; } + /** + * Set current page. + */ + public function setCurrent(string $path): void + { + reset($this->items); + + while (key($this->items) !== $path && key($this->items) !== null) { + next($this->items); + } + } + /** * Returns current page. *