Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[HttpFoudation] CS, more tests and some optimization.

  • Loading branch information...
commit 910b5c7f834776f6ac074c0e00b4dfcde39a2b2b 1 parent b0466e8
Drak authored
View
4 src/Symfony/Bundle/FrameworkBundle/Templating/Helper/SessionHelper.php
@@ -46,9 +46,9 @@ public function get($name, $default = null)
return $this->session->get($name, $default);
}
- public function getFlash($name, $default = null)
+ public function getFlash($name, array $default = array())
{
- return $this->session->getFlashBag()->get($name);
+ return $this->session->getFlashBag()->get($name, $default);
}
public function getFlashes()
View
8 src/Symfony/Component/HttpFoundation/Session/Flash/AutoExpireFlashBag.php
@@ -139,8 +139,7 @@ public function setAll(array $messages)
*/
public function set($type, $messages)
{
- $messages = (array)$messages;
- $this->flashes['new'][$type] = $messages;
+ $this->flashes['new'][$type] = (array)$messages;
}
/**
@@ -172,9 +171,6 @@ public function getStorageKey()
*/
public function clear()
{
- $return = $this->all();
- $this->flashes = array('display' => array(), 'new' => array());
-
- return $return;
+ return $this->all();
}
}
View
3  src/Symfony/Component/HttpFoundation/Session/Flash/FlashBag.php
@@ -121,8 +121,7 @@ public function all()
*/
public function set($type, $messages)
{
- $messages = (array)$messages;
- $this->flashes[$type] = $messages;
+ $this->flashes[$type] = (array) $messages;
}
/**
View
1  src/Symfony/Component/HttpFoundation/Session/Session.php
@@ -310,5 +310,4 @@ public function clearFlashes()
{
return $this->getBag($this->flashName)->clear();
}
-
}
View
2  tests/Symfony/Tests/Component/HttpFoundation/Session/Flash/AutoExpireFlashBagTest.php
@@ -150,6 +150,6 @@ public function testAll()
public function testClear()
{
- $this->assertEquals(array('notice' => 'A previous flash message'), $this->bag->clear());
+ $this->assertEquals(array('notice' => array('A previous flash message')), $this->bag->clear());
}
}
View
10 tests/Symfony/Tests/Component/HttpFoundation/Session/SessionTest.php
@@ -175,13 +175,21 @@ public function testGetSetFlashes()
$this->session->setFlashes($array);
$this->assertEquals($array, $this->session->getFlashes());
$this->assertEquals(array(), $this->session->getFlashes());
+ $this->session->getFlashBag()->add('notice', 'foo');
+
+ // test that BC works by only retrieving the first added.
+ $this->session->getFlashBag()->add('notice', 'foo2');
+ $this->assertEquals(array('notice' => 'foo'), $this->session->getFlashes());
}
public function testGetSetFlash()
{
$this->assertNull($this->session->getFlash('notice'));
$this->assertEquals('default', $this->session->getFlash('notice', 'default'));
- $this->session->setFlash('notice', 'foo');
+ $this->session->getFlashBag()->add('notice', 'foo');
+ $this->session->getFlashBag()->add('notice', 'foo2');
+
+ // test that BC works by only retrieving the first added.
$this->assertEquals('foo', $this->session->getFlash('notice'));
$this->assertNull($this->session->getFlash('notice'));
}
Please sign in to comment.
Something went wrong with that request. Please try again.