Skip to content

Commit

Permalink
Added posibility to set up session section name for rememberState fea…
Browse files Browse the repository at this point in the history
…ture
  • Loading branch information
brabijan authored and o5 committed Oct 14, 2015
1 parent 46f6f1e commit 8694c95
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ class Grid extends Components\Container
/** @var bool */
protected $rememberState = FALSE;

/** @var string */
protected $rememberStateSectionName;

/** @var string */
protected $primaryKey = 'id';

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 8694c95

Please sign in to comment.