From 35e9d9c9ad336c60f97cd70e535788455211c7af Mon Sep 17 00:00:00 2001 From: Michal Gebauer Date: Thu, 3 Jul 2014 23:17:09 +0200 Subject: [PATCH 1/2] Refactored flash session to Http\FlashSession --- src/Application/UI/Presenter.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Application/UI/Presenter.php b/src/Application/UI/Presenter.php index 3cb1478f9..17a5dc08e 100644 --- a/src/Application/UI/Presenter.php +++ b/src/Application/UI/Presenter.php @@ -45,6 +45,8 @@ abstract class Presenter extends Control implements Application\IPresenter FLASH_KEY = '_fid', DEFAULT_ACTION = 'default'; + const FLASH_SESSION_NAMESPACE = 'Nette.Application.Flash'; + /** @var int */ public $invalidLinkMode; @@ -1285,7 +1287,7 @@ public function popGlobalParameters($id) public function hasFlashSession() { return !empty($this->params[self::FLASH_KEY]) - && $this->getSession()->hasSection('Nette.Application.Flash/' . $this->params[self::FLASH_KEY]); + && $this->getFlashSession()->hasSection(self::FLASH_SESSION_NAMESPACE); } @@ -1296,9 +1298,14 @@ public function hasFlashSession() public function getFlashSession() { if (empty($this->params[self::FLASH_KEY])) { - $this->params[self::FLASH_KEY] = Nette\Utils\Random::generate(4); + $this->params[self::FLASH_KEY] = Http\FlashSession::generateID(); + } + + if ($this->flashSession === NULL) { + $this->flashSession = new Http\FlashSession($this->params[self::FLASH_KEY], $this->session); } - return $this->getSession('Nette.Application.Flash/' . $this->params[self::FLASH_KEY]); + + return $this->getSession(self::FLASH_SESSION_NAMESPACE); } From c7e39c005a1364c31c802d697685d1fe0c91ab91 Mon Sep 17 00:00:00 2001 From: Michal Gebauer Date: Thu, 3 Jul 2014 23:54:55 +0200 Subject: [PATCH 2/2] ID => Id [Coding Standard] --- src/Application/UI/Presenter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Application/UI/Presenter.php b/src/Application/UI/Presenter.php index 17a5dc08e..5b59f29db 100644 --- a/src/Application/UI/Presenter.php +++ b/src/Application/UI/Presenter.php @@ -1298,7 +1298,7 @@ public function hasFlashSession() public function getFlashSession() { if (empty($this->params[self::FLASH_KEY])) { - $this->params[self::FLASH_KEY] = Http\FlashSession::generateID(); + $this->params[self::FLASH_KEY] = Http\FlashSession::generateId(); } if ($this->flashSession === NULL) {