Fix keying in SessionHelper::flash()

It shouldb e looking for the plugin in the params key.  This
makes SessionHelper compatible with SessionComponent.
This commit is contained in:
mark_story 2011-11-12 11:54:57 -05:00
parent 3ad50a2591
commit 92688e2a49
2 changed files with 13 additions and 3 deletions

View file

@ -183,7 +183,7 @@ class SessionHelperTest extends CakeTestCase {
$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);

View file

@ -100,6 +100,16 @@ class SessionHelper extends AppHelper {
* 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 @@ class SessionHelper extends AppHelper {
$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;