From 1d1c10f0a64c25c18368d3191a8077cc804faa23 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Wed, 27 Oct 2021 14:59:23 +0300 Subject: [PATCH] Added method `Page::initialize()` --- CHANGELOG.md | 2 +- system/src/Grav/Common/Page/Page.php | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5de83960a..66f07b665 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ 1. [](#improved) * Added `route` and `request` to `onPagesInitialized` event - * Improved page cloning + * Improved page cloning, added method `Page::initialize()` # v1.7.24 ## 10/26/2021 diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index 379f9bf58..11b9790cc 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -220,10 +220,21 @@ class Page implements PageInterface public function __clone() { + $this->initialized = false; $this->header = $this->header ? clone $this->header : null; - $this->route = null; - $this->raw_route = null; - $this->_forms = null; + } + + /** + * @return void + */ + public function initialize(): void + { + if (!$this->initialized) { + $this->initialized = true; + $this->route = null; + $this->raw_route = null; + $this->_forms = null; + } } /**