From effac3b2d6dd241596d2ef51d4f73c05ae07a8d0 Mon Sep 17 00:00:00 2001 From: John Koster Date: Sun, 3 Mar 2024 11:17:16 -0600 Subject: [PATCH 1/2] Cache structure call on page instances --- src/Structures/Page.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Structures/Page.php b/src/Structures/Page.php index 7455bd64d3..8c3da6ceef 100644 --- a/src/Structures/Page.php +++ b/src/Structures/Page.php @@ -39,6 +39,7 @@ class Page implements Arrayable, ArrayAccess, Augmentable, Entry, JsonSerializab protected $title; protected $depth; protected $data = []; + protected $structure; public function __construct() { @@ -393,7 +394,11 @@ public function toResponse($request) public function structure() { - return $this->tree->structure(); + if ($this->structure !== null) { + return $this->structure; + } + + return $this->structure = $this->tree->structure(); } public function routeData() From b32e82b7cb0a484d8acf90d93c4f0a421ad38293 Mon Sep 17 00:00:00 2001 From: Jason Varga Date: Tue, 12 Mar 2024 10:50:18 -0400 Subject: [PATCH 2/2] visibility --- src/Structures/Page.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Structures/Page.php b/src/Structures/Page.php index 8c3da6ceef..cd14fc0386 100644 --- a/src/Structures/Page.php +++ b/src/Structures/Page.php @@ -39,7 +39,7 @@ class Page implements Arrayable, ArrayAccess, Augmentable, Entry, JsonSerializab protected $title; protected $depth; protected $data = []; - protected $structure; + private $structure; public function __construct() {