From 8694c9509c5c05e6e67afae58aebdf8621a0beda Mon Sep 17 00:00:00 2001 From: Jan Brabec Date: Thu, 10 Sep 2015 11:31:12 +0200 Subject: [PATCH] Added posibility to set up session section name for rememberState feature --- src/Grid.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Grid.php b/src/Grid.php index 6e9ebc02..544e367e 100755 --- a/src/Grid.php +++ b/src/Grid.php @@ -82,6 +82,9 @@ class Grid extends Components\Container /** @var bool */ protected $rememberState = FALSE; + /** @var string */ + protected $rememberStateSectionName; + /** @var string */ protected $primaryKey = 'id'; @@ -275,13 +278,15 @@ public function setTemplateFile($file) /** * Sets saving state to session. * @param bool $state + * @param string $sectionName * @return Grid */ - public function setRememberState($state = TRUE) + public function setRememberState($state = TRUE, $sectionName = NULL) { $this->getPresenter(); //component must be attached to presenter $this->getRememberSession(TRUE); //start session if not $this->rememberState = (bool) $state; + $this->rememberStateSectionName = $sectionName; return $this; } @@ -498,7 +503,7 @@ public function getRememberSession($forceStart = FALSE) } return $session->isStarted() - ? ($session->getSection($presenter->name . ':' . $this->getUniqueId())) + ? ($session->getSection($this->rememberStateSectionName ?: ($presenter->name . ':' . $this->getUniqueId()))) : NULL; }