From e54f0f6aef511048b6d1d3361397e126c4dd936e Mon Sep 17 00:00:00 2001 From: John Koster Date: Sun, 25 Feb 2024 18:54:09 -0600 Subject: [PATCH 1/3] Update AugmentedPage.php --- src/Structures/AugmentedPage.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Structures/AugmentedPage.php b/src/Structures/AugmentedPage.php index a3dd2d635dc..0d953dbd046 100644 --- a/src/Structures/AugmentedPage.php +++ b/src/Structures/AugmentedPage.php @@ -9,6 +9,7 @@ class AugmentedPage extends AugmentedEntry { protected $page; protected $hasEntry = false; + protected $fieldsCache = null; public function __construct($page) { @@ -57,16 +58,20 @@ protected function getFromData($key) protected function blueprintFields() { - $fields = ($pageBlueprint = $this->page->blueprint()) - ? $pageBlueprint->fields()->all() - : collect(); + if ($this->fieldsCache === null) { + $fields = ($pageBlueprint = $this->page->blueprint()) + ? $pageBlueprint->fields()->all() + : collect(); - if ($this->page !== $this->data) { - $entryFields = $this->data->blueprint()->fields()->all(); - $fields = $entryFields->merge($fields); + if ($this->page !== $this->data) { + $entryFields = $this->data->blueprint()->fields()->all(); + $fields = $entryFields->merge($fields); + } + + $this->fieldsCache = $fields; } - return $fields; + return $this->fieldsCache; } protected function id() From 1237cabb02ac05799c2523939285ebb23d507055 Mon Sep 17 00:00:00 2001 From: Jason Varga Date: Mon, 26 Feb 2024 10:20:33 -0500 Subject: [PATCH 2/3] use guard to avoid changing indentation --- src/Structures/AugmentedPage.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Structures/AugmentedPage.php b/src/Structures/AugmentedPage.php index 0d953dbd046..49a29166fec 100644 --- a/src/Structures/AugmentedPage.php +++ b/src/Structures/AugmentedPage.php @@ -58,20 +58,20 @@ protected function getFromData($key) protected function blueprintFields() { - if ($this->fieldsCache === null) { - $fields = ($pageBlueprint = $this->page->blueprint()) - ? $pageBlueprint->fields()->all() - : collect(); + if ($this->fieldsCache) { + return $this->fieldsCache; + } - if ($this->page !== $this->data) { - $entryFields = $this->data->blueprint()->fields()->all(); - $fields = $entryFields->merge($fields); - } + $fields = ($pageBlueprint = $this->page->blueprint()) + ? $pageBlueprint->fields()->all() + : collect(); - $this->fieldsCache = $fields; + if ($this->page !== $this->data) { + $entryFields = $this->data->blueprint()->fields()->all(); + $fields = $entryFields->merge($fields); } - return $this->fieldsCache; + return $this->fieldsCache = $fields; } protected function id() From 1cf9c549b57665632d5842588cdf468bd2134d6b Mon Sep 17 00:00:00 2001 From: Jason Varga Date: Tue, 12 Mar 2024 12:49:40 -0400 Subject: [PATCH 3/3] visibility --- src/Structures/AugmentedPage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Structures/AugmentedPage.php b/src/Structures/AugmentedPage.php index 49a29166fec..22b9683236a 100644 --- a/src/Structures/AugmentedPage.php +++ b/src/Structures/AugmentedPage.php @@ -9,7 +9,7 @@ class AugmentedPage extends AugmentedEntry { protected $page; protected $hasEntry = false; - protected $fieldsCache = null; + private $fieldsCache; public function __construct($page) {