mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
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:
parent
3ad50a2591
commit
92688e2a49
2 changed files with 13 additions and 3 deletions
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue