diff --git a/lib/Cake/Controller/Component/FlashComponent.php b/lib/Cake/Controller/Component/FlashComponent.php index cab43f305..3605481d9 100644 --- a/lib/Cake/Controller/Component/FlashComponent.php +++ b/lib/Cake/Controller/Component/FlashComponent.php @@ -82,12 +82,18 @@ class FlashComponent extends Component { } $options['element'] = $plugin . 'Flash/' . $element; - CakeSession::write('Message.' . $options['key'], array( + $messages = CakeSession::read('Message.' . $options['key']); + + $newMessage = array( 'message' => $message, 'key' => $options['key'], 'element' => $options['element'], 'params' => $options['params'] - )); + ); + + $messages[] = $newMessage; + + CakeSession::write('Message.' . $options['key'], $messages); } /** diff --git a/lib/Cake/Test/Case/Controller/Component/FlashComponentTest.php b/lib/Cake/Test/Case/Controller/Component/FlashComponentTest.php index 64fe0ec7f..dac0ec090 100644 --- a/lib/Cake/Test/Case/Controller/Component/FlashComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/FlashComponentTest.php @@ -59,10 +59,12 @@ class FlashComponentTest extends CakeTestCase { $this->Flash->set('This is a test message'); $expected = array( - 'message' => 'This is a test message', - 'key' => 'flash', - 'element' => 'Flash/default', - 'params' => array() + array( + 'message' => 'This is a test message', + 'key' => 'flash', + 'element' => 'Flash/default', + 'params' => array() + ) ); $result = CakeSession::read('Message.flash'); $this->assertEquals($expected, $result); @@ -72,30 +74,36 @@ class FlashComponentTest extends CakeTestCase { 'params' => array('foo' => 'bar') )); $expected = array( - 'message' => 'This is a test message', - 'key' => 'flash', - 'element' => 'Flash/test', - 'params' => array('foo' => 'bar') + array( + 'message' => 'This is a test message', + 'key' => 'flash', + 'element' => 'Flash/test', + 'params' => array('foo' => 'bar') + ) ); $result = CakeSession::read('Message.flash'); $this->assertEquals($expected, $result); $this->Flash->set('This is a test message', array('element' => 'MyPlugin.alert')); $expected = array( - 'message' => 'This is a test message', - 'key' => 'flash', - 'element' => 'MyPlugin.Flash/alert', - 'params' => array() + array( + 'message' => 'This is a test message', + 'key' => 'flash', + 'element' => 'MyPlugin.Flash/alert', + 'params' => array() + ) ); $result = CakeSession::read('Message.flash'); $this->assertEquals($expected, $result); $this->Flash->set('This is a test message', array('key' => 'foobar')); $expected = array( - 'message' => 'This is a test message', - 'key' => 'foobar', - 'element' => 'Flash/default', - 'params' => array() + array( + 'message' => 'This is a test message', + 'key' => 'foobar', + 'element' => 'Flash/default', + 'params' => array() + ) ); $result = CakeSession::read('Message.foobar'); $this->assertEquals($expected, $result); @@ -111,10 +119,12 @@ class FlashComponentTest extends CakeTestCase { $this->Flash->set(new Exception('This is a test message', 404)); $expected = array( - 'message' => 'This is a test message', - 'key' => 'flash', - 'element' => 'Flash/default', - 'params' => array('code' => 404) + array( + 'message' => 'This is a test message', + 'key' => 'flash', + 'element' => 'Flash/default', + 'params' => array('code' => 404) + ) ); $result = CakeSession::read('Message.flash'); $this->assertEquals($expected, $result); @@ -131,10 +141,12 @@ class FlashComponentTest extends CakeTestCase { $FlashWithSettings = $this->Components->load('Flash', array('element' => 'test')); $FlashWithSettings->set('This is a test message'); $expected = array( - 'message' => 'This is a test message', - 'key' => 'flash', - 'element' => 'Flash/test', - 'params' => array() + array( + 'message' => 'This is a test message', + 'key' => 'flash', + 'element' => 'Flash/test', + 'params' => array() + ) ); $result = CakeSession::read('Message.flash'); $this->assertEquals($expected, $result); diff --git a/lib/Cake/View/Helper/FlashHelper.php b/lib/Cake/View/Helper/FlashHelper.php index ec26631fa..3675a8245 100644 --- a/lib/Cake/View/Helper/FlashHelper.php +++ b/lib/Cake/View/Helper/FlashHelper.php @@ -82,10 +82,15 @@ class FlashHelper extends AppHelper { )); } - $flash = $options + $flash; CakeSession::delete("Message.$key"); - $flash['key'] = $key; - return $this->_View->element($flash['element'], $flash); + $out = ''; + foreach ($flash as $message) { + $message['key'] = $key; + $message = $options + $message; + $out .= $this->_View->element($message['element'], $message); + } + + return $out; } }