From 898ef9ba31f9727a093d4c67bae5f726eed458b2 Mon Sep 17 00:00:00 2001 From: Niklas Forsdahl Date: Thu, 20 Jun 2024 15:06:56 +0300 Subject: [PATCH] Removed custom interface for SessionGridFieldStateManager, the extra methods will be incorporated into GridFieldStateManagerInterface in the future. --- .../GridField/GridFieldDetailForm_ItemRequest.php | 2 +- src/Forms/GridField/GridFieldStateStoreInterface.php | 10 ---------- src/Forms/GridField/GridState_Data.php | 4 +++- src/Forms/GridField/SessionGridFieldStateManager.php | 2 +- 4 files changed, 5 insertions(+), 13 deletions(-) delete mode 100644 src/Forms/GridField/GridFieldStateStoreInterface.php diff --git a/src/Forms/GridField/GridFieldDetailForm_ItemRequest.php b/src/Forms/GridField/GridFieldDetailForm_ItemRequest.php index f17d579b4..dacca37ed 100644 --- a/src/Forms/GridField/GridFieldDetailForm_ItemRequest.php +++ b/src/Forms/GridField/GridFieldDetailForm_ItemRequest.php @@ -454,7 +454,7 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler $gridState = $this->gridField->getState(false); $actions->push(HiddenField::create($manager->getStateKey($this->gridField), null, $gridState)); - if ($manager instanceof GridFieldStateStoreInterface) { + if (ClassInfo::hasMethod($manager, 'getStateRequestVar')) { $stateRequestVar = $manager->getStateRequestVar(); $stateValue = $this->getRequest()->requestVar($stateRequestVar); if ($stateValue) { diff --git a/src/Forms/GridField/GridFieldStateStoreInterface.php b/src/Forms/GridField/GridFieldStateStoreInterface.php deleted file mode 100644 index 2037ad8ea..000000000 --- a/src/Forms/GridField/GridFieldStateStoreInterface.php +++ /dev/null @@ -1,10 +0,0 @@ -getStateManager(); - if ($stateManager instanceof GridFieldStateStoreInterface) { + if (ClassInfo::hasMethod($stateManager, 'storeState')) { $stateManager->storeState($this->state->getGridField(), $this->state->Value()); } } diff --git a/src/Forms/GridField/SessionGridFieldStateManager.php b/src/Forms/GridField/SessionGridFieldStateManager.php index 750c1f336..4ed3133ea 100644 --- a/src/Forms/GridField/SessionGridFieldStateManager.php +++ b/src/Forms/GridField/SessionGridFieldStateManager.php @@ -11,7 +11,7 @@ use SilverStripe\Control\HTTPRequest; * (i.e. the state is changed from the default). * If a session state key is present in the request, it will always be used instead of generating a new one. */ -class SessionGridFieldStateManager implements GridFieldStateManagerInterface, GridFieldStateStoreInterface +class SessionGridFieldStateManager implements GridFieldStateManagerInterface { protected static $state_ids = [];