Skip to content

Commit

Permalink
[HttpFoundation] fixed flash management
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Mar 11, 2011
1 parent a1fcbf4 commit bc6ffee
Show file tree
Hide file tree
Showing 2 changed files with 171 additions and 196 deletions.
26 changes: 21 additions & 5 deletions src/Symfony/Component/HttpFoundation/Session.php
Expand Up @@ -223,6 +223,7 @@ public function setFlashes($values)
}

$this->attributes['_flash'] = $values;
$this->oldFlashes = array();
}

public function getFlash($name, $default = null)
Expand All @@ -242,27 +243,42 @@ public function setFlash($name, $value)

public function hasFlash($name)
{
if (false === $this->started) {
$this->start();
}

return array_key_exists($name, $this->attributes['_flash']);
}

public function removeFlash($name)
{
if (false === $this->started) {
$this->start();
}

unset($this->attributes['_flash'][$name]);
}

public function clearFlashes()
{
if (false === $this->started) {
$this->start();
}

$this->attributes['_flash'] = array();
$this->oldFlashes = array();
}

public function save()
{
if (true === $this->started) {
if (isset($this->attributes['_flash'])) {
$this->attributes['_flash'] = array_diff_key($this->attributes['_flash'], $this->oldFlashes);
}
$this->storage->write('_symfony2', $this->attributes);
if (false === $this->started) {
$this->start();
}

if (isset($this->attributes['_flash'])) {
$this->attributes['_flash'] = array_diff_key($this->attributes['_flash'], $this->oldFlashes);
}
$this->storage->write('_symfony2', $this->attributes);
}

public function __destruct()
Expand Down

0 comments on commit bc6ffee

Please sign in to comment.