Skip to content

Commit

Permalink
UI\Presenter: own flash storage replaced with session flash storage
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jul 1, 2014
1 parent a7c55b5 commit c9e457c
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions src/Application/UI/Presenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ abstract class Presenter extends Control implements Application\IPresenter
/** @internal special parameter key */
const SIGNAL_KEY = 'do',
ACTION_KEY = 'action',
FLASH_KEY = '_fid',
FLASH_KEY = Http\Session::FLASH_KEY,
DEFAULT_ACTION = 'default';

/** @var int */
Expand Down Expand Up @@ -237,10 +237,6 @@ public function run(Application\Request $request)
}
} catch (Application\AbortException $e) { }

if ($this->hasFlashSession()) {
$this->getFlashSession()->setExpiration($this->response instanceof Responses\RedirectResponse ? '+ 30 seconds' : '+ 3 seconds');
}

// SHUTDOWN
$this->onShutdown($this, $this->response);
$this->shutdown($this->response);
Expand Down Expand Up @@ -951,8 +947,8 @@ protected function createRequest($component, $destination, array $args, $mode)
$args[self::SIGNAL_KEY] = $component->getParameterId($signal);
$current = $current && $args[self::SIGNAL_KEY] === $this->getParameter(self::SIGNAL_KEY);
}
if (($mode === 'redirect' || $mode === 'forward') && $this->hasFlashSession()) {
$args[self::FLASH_KEY] = $this->getParameter(self::FLASH_KEY);
if ($mode === 'redirect' || $mode === 'forward') {
$args[Http\Session::FLASH_KEY] = $this->getSession()->getFlashId();
}

$this->lastCreatedRequest = new Application\Request(
Expand Down Expand Up @@ -1103,7 +1099,7 @@ public function restoreRequest($key)
unset($session[$key]);
$request->setFlag(Application\Request::RESTORED, TRUE);
$params = $request->getParameters();
$params[self::FLASH_KEY] = $this->getParameter(self::FLASH_KEY);
$params[Http\Session::FLASH_KEY] = $this->getSession()->getFlashId();
$request->setParameters($params);
$this->sendResponse(new Responses\ForwardResponse($request));
}
Expand Down Expand Up @@ -1284,8 +1280,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]);
return (bool) $this->getSession()->getFlashId();
}


Expand All @@ -1295,10 +1290,7 @@ public function hasFlashSession()
*/
public function getFlashSession()
{
if (empty($this->params[self::FLASH_KEY])) {
$this->params[self::FLASH_KEY] = Nette\Utils\Random::generate(4);
}
return $this->getSession('Nette.Application.Flash/' . $this->params[self::FLASH_KEY]);
return $this->getSession()->getFlashSection('Nette.Application.Flash');
}


Expand Down

0 comments on commit c9e457c

Please sign in to comment.