Removed custom interface for SessionGridFieldStateManager, the extra methods

will be incorporated into GridFieldStateManagerInterface in the future.
This commit is contained in:
Niklas Forsdahl 2024-06-20 15:06:56 +03:00
parent e9cd597a22
commit 898ef9ba31
4 changed files with 5 additions and 13 deletions

View File

@ -454,7 +454,7 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler
$gridState = $this->gridField->getState(false); $gridState = $this->gridField->getState(false);
$actions->push(HiddenField::create($manager->getStateKey($this->gridField), null, $gridState)); $actions->push(HiddenField::create($manager->getStateKey($this->gridField), null, $gridState));
if ($manager instanceof GridFieldStateStoreInterface) { if (ClassInfo::hasMethod($manager, 'getStateRequestVar')) {
$stateRequestVar = $manager->getStateRequestVar(); $stateRequestVar = $manager->getStateRequestVar();
$stateValue = $this->getRequest()->requestVar($stateRequestVar); $stateValue = $this->getRequest()->requestVar($stateRequestVar);
if ($stateValue) { if ($stateValue) {

View File

@ -1,10 +0,0 @@
<?php
namespace SilverStripe\Forms\GridField;
interface GridFieldStateStoreInterface
{
public function storeState(GridField $gridField, $value = null);
public function getStateRequestVar(): string;
}

View File

@ -2,6 +2,8 @@
namespace SilverStripe\Forms\GridField; namespace SilverStripe\Forms\GridField;
use SilverStripe\Core\ClassInfo;
/** /**
* Simple set of data, similar to stdClass, but without the notice-level * Simple set of data, similar to stdClass, but without the notice-level
* errors. * errors.
@ -86,7 +88,7 @@ class GridState_Data
public function storeData() public function storeData()
{ {
$stateManager = $this->getStateManager(); $stateManager = $this->getStateManager();
if ($stateManager instanceof GridFieldStateStoreInterface) { if (ClassInfo::hasMethod($stateManager, 'storeState')) {
$stateManager->storeState($this->state->getGridField(), $this->state->Value()); $stateManager->storeState($this->state->getGridField(), $this->state->Value());
} }
} }

View File

@ -11,7 +11,7 @@ use SilverStripe\Control\HTTPRequest;
* (i.e. the state is changed from the default). * (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. * 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 = []; protected static $state_ids = [];