diff --git a/README.md b/README.md
index 25c8049..ffc4736 100644
--- a/README.md
+++ b/README.md
@@ -17,13 +17,17 @@ This module is intended to replicate and expand upon the functionality provided
## Requirements
-Silverstripe 4.0 (3.1+ through previous releases)
+Silverstripe 5.0 (4.0 and 3.1+ through previous releases)
## Installation
**Composer / Packagist ([best practice](http://doc.silverstripe.org/framework/en/trunk/installation/composer))**
Add "jonom/silverstripe-betternavigator" to your requirements.
+```
+composer require jonom/silverstripe-betternavigator
+```
+
**Manually**
Download, place the folder in your project root, rename it to 'betternavigator' (if applicable) and run a dev/build?flush=1.
diff --git a/composer.json b/composer.json
index a5f125b..027fd78 100644
--- a/composer.json
+++ b/composer.json
@@ -16,7 +16,7 @@
}
],
"require": {
- "silverstripe/framework": "^4.0"
+ "silverstripe/framework": "^5"
},
"extra": {
"installer-name": "betternavigator",
diff --git a/src/Extension/BetterNavigatorExtension.php b/src/Extension/BetterNavigatorExtension.php
index 72acdc1..5d8d83e 100644
--- a/src/Extension/BetterNavigatorExtension.php
+++ b/src/Extension/BetterNavigatorExtension.php
@@ -2,7 +2,7 @@
namespace JonoM\BetterNavigator\Extension;
-use SilverStripe\CMS\Controllers\SilverStripeNavigator;
+use SilverStripe\Admin\Navigator\SilverStripeNavigator;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Control\Controller;
use SilverStripe\Control\Director;
@@ -23,6 +23,11 @@ class BetterNavigatorExtension extends DataExtension
private static $better_navigator_edit_permission = 'CMS_ACCESS_CMSMain';
private static $better_navigator_edit_permission_mode = 'any';
+ /**
+ * Extensions are singleton, so any cached results need to use a unique key
+ */
+ private $shouldDisplay = [];
+
/**
* @param $request
* @param $action
@@ -161,13 +166,16 @@ private function generateNavigator()
*/
private function shouldDisplay()
{
- if ($this->owner->getField('_betterNavigatorShouldDisplay') !== null) {
- return $this->owner->getField('_betterNavigatorShouldDisplay');
+ $key = $this->owner->getUniqueKey();
+
+ if (array_key_exists($key, $this->shouldDisplay)) {
+ return $this->shouldDisplay[$key];
}
// Make sure this is a page
if (!$this->owner->showBetterNavigator()) {
- $this->owner->setField('_betterNavigatorShouldDisplay', false);
+ $this->shouldDisplay[$key] = false;
+
return false;
}
@@ -176,7 +184,8 @@ private function shouldDisplay()
$canViewDraft = (Permission::check('VIEW_DRAFT_CONTENT') || Permission::check('CMS_ACCESS_CMSMain'));
$result = ($isDev || $canViewDraft);
- $this->owner->setField('_betterNavigatorShouldDisplay', $result);
+ $this->shouldDisplay[$key] = $result;
+
return $result;
}
diff --git a/templates/BetterNavigator/BetterNavigator.ss b/templates/BetterNavigator/BetterNavigator.ss
index 443eea6..2d95dca 100644
--- a/templates/BetterNavigator/BetterNavigator.ss
+++ b/templates/BetterNavigator/BetterNavigator.ss
@@ -62,14 +62,14 @@
<%t JonoM\BetterNavigator.FLUSH_CACHE_LABEL 'Flush caches' %>
-
<%t JonoM\BetterNavigator.BUILD_DATABASE_LABEL 'Build database' %>
- <%t JonoM\BetterNavigator.DEV_MENU_LABEL 'Dev menu' %>
+ <%t JonoM\BetterNavigator.DEV_MENU_LABEL 'Dev menu' %>