Skip to content

Commit

Permalink
Fix keying in SessionHelper::flash()
Browse files Browse the repository at this point in the history
It shouldb e looking for the plugin in the params key.  This
makes SessionHelper compatible with SessionComponent.
  • Loading branch information
markstory committed Nov 12, 2011
1 parent 3ad50a2 commit 92688e2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/Cake/Test/Case/View/Helper/SessionHelperTest.php
Expand Up @@ -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);
Expand Down
14 changes: 12 additions & 2 deletions lib/Cake/View/Helper/SessionHelper.php
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 92688e2

Please sign in to comment.