Permalink
Browse files

Fix keying in SessionHelper::flash()

It shouldb e looking for the plugin in the params key.  This
makes SessionHelper compatible with SessionComponent.
  • Loading branch information...
1 parent 3ad50a2 commit 92688e2a496346de7c393936b4f7537ed9e07503 @markstory markstory committed Nov 12, 2011
Showing with 13 additions and 3 deletions.
  1. +1 −1 lib/Cake/Test/Case/View/Helper/SessionHelperTest.php
  2. +12 −2 lib/Cake/View/Helper/SessionHelper.php
@@ -183,7 +183,7 @@ public function testFlashWithPluginElement() {
$result = $this->Session->flash('flash', array(
'element' => 'plugin_element',
- 'plugin' => 'TestPlugin'
+ 'params' => array('plugin' => 'TestPlugin')
));
$expected = 'this is the plugin element using params[plugin]';
$this->assertEquals($expected, $result);
@@ -100,6 +100,16 @@ public function error() {
* echo $this->Session->flash('flash', array('element' => 'my_custom_element'));
* }}}
*
+ * If you want to use an element from a plugin for rendering your flash message you can do that using the
+ * plugin param:
+ *
+ * {{{
+ * echo $this->Session->flash('flash', array(
+ * 'element' => 'my_custom_element',
+ * 'params' => array('plugin' => 'my_plugin')
+ * ));
+ * }}}
+ *
* @param string $key The [Message.]key you are rendering in the view.
* @param array $attrs Additional attributes to use for the creation of this flash message.
* Supports the 'params', and 'element' keys that are used in the helper.
@@ -129,8 +139,8 @@ public function flash($key = 'flash', $attrs = array()) {
$out = $message;
} else {
$options = array();
- if (isset($flash['plugin'])) {
- $options['plugin'] = $flash['plugin'];
+ if (isset($flash['params']['plugin'])) {
+ $options['plugin'] = $flash['params']['plugin'];
}
$tmpVars = $flash['params'];
$tmpVars['message'] = $message;

0 comments on commit 92688e2

Please sign in to comment.