Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored flash session to Http\FlashSession #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/Application/UI/Presenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

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


Expand All @@ -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);
}


Expand Down