2018-11-21 16:55:57 +13:00
|
|
|
<?php
|
|
|
|
namespace SilverStripe\Forms\GridField\FormAction;
|
|
|
|
|
|
|
|
use SilverStripe\Control\HTTPRequest;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Stores GridField action state in the session in exactly the same way it has in the past
|
|
|
|
*/
|
2018-11-22 13:05:43 +13:00
|
|
|
class SessionStore extends AbstractRequestAwareStore implements StateStore
|
2018-11-21 16:55:57 +13:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Save the given state against the given ID returning an associative array to be added as attributes on the form
|
|
|
|
* action
|
|
|
|
*
|
|
|
|
* @param string $id
|
|
|
|
* @param array $state
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function save($id, array $state)
|
|
|
|
{
|
2018-11-22 13:05:43 +13:00
|
|
|
$this->getRequest()->getSession()->set($id, $state);
|
2018-11-21 16:55:57 +13:00
|
|
|
|
|
|
|
// This adapter does not require any additional attributes...
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load state for a given ID
|
|
|
|
*
|
|
|
|
* @param string $id
|
2018-11-22 13:05:43 +13:00
|
|
|
* @return array
|
2018-11-21 16:55:57 +13:00
|
|
|
*/
|
|
|
|
public function load($id)
|
|
|
|
{
|
2018-11-22 13:05:43 +13:00
|
|
|
return (array) $this->getRequest()->getSession()->get($id);
|
2018-11-21 16:55:57 +13:00
|
|
|
}
|
|
|
|
}
|