mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 00:48:25 +00:00
Merge pull request #9972 from chinpei215/2.x-flash-helper
Fix FlashHelper::render() cannot render `default` messages
This commit is contained in:
commit
f62d2a84ea
2 changed files with 19 additions and 0 deletions
|
@ -76,6 +76,12 @@ class FlashHelperTest extends CakeTestCase {
|
||||||
'message' => 'Recorded',
|
'message' => 'Recorded',
|
||||||
'element' => 'flash_classy',
|
'element' => 'flash_classy',
|
||||||
'params' => array()
|
'params' => array()
|
||||||
|
),
|
||||||
|
'default' => array(
|
||||||
|
'key' => 'default',
|
||||||
|
'message' => 'Default',
|
||||||
|
'element' => 'default',
|
||||||
|
'params' => array()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
@ -154,4 +160,13 @@ class FlashHelperTest extends CakeTestCase {
|
||||||
$expected = 'this is the plugin element';
|
$expected = 'this is the plugin element';
|
||||||
$this->assertContains($expected, $result);
|
$this->assertContains($expected, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that the default element fallbacks to the Flash/default element.
|
||||||
|
*/
|
||||||
|
public function testFlashFallback() {
|
||||||
|
$result = $this->Flash->render('default');
|
||||||
|
$expected = '<div class="message">Default</div>';
|
||||||
|
$this->assertContains($expected, $result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,6 +86,10 @@ class FlashHelper extends AppHelper {
|
||||||
CakeSession::delete("Message.$key");
|
CakeSession::delete("Message.$key");
|
||||||
$flash['key'] = $key;
|
$flash['key'] = $key;
|
||||||
|
|
||||||
|
if ($flash['element'] === 'default') {
|
||||||
|
$flash['element'] = 'Flash/default';
|
||||||
|
}
|
||||||
|
|
||||||
return $this->_View->element($flash['element'], $flash);
|
return $this->_View->element($flash['element'], $flash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue