Allowing Controller::flash() layout to be set with a parameter. Fixes #5034

This commit is contained in:
mark_story 2009-08-27 23:40:36 -04:00
parent 24448775c2
commit 29de5e515f
2 changed files with 10 additions and 2 deletions

View file

@ -917,17 +917,18 @@ class Controller extends Object {
* @param string $message Message to display to the user * @param string $message Message to display to the user
* @param mixed $url Relative string or array-based URL to redirect to after the time expires * @param mixed $url Relative string or array-based URL to redirect to after the time expires
* @param integer $pause Time to show the message * @param integer $pause Time to show the message
* @param string $layout Layout you want to use, defaults to 'flash'
* @return void Renders flash layout * @return void Renders flash layout
* @access public * @access public
* @link http://book.cakephp.org/view/426/flash * @link http://book.cakephp.org/view/426/flash
*/ */
function flash($message, $url, $pause = 1) { function flash($message, $url, $pause = 1, $layout = 'flash') {
$this->autoRender = false; $this->autoRender = false;
$this->set('url', Router::url($url)); $this->set('url', Router::url($url));
$this->set('message', $message); $this->set('message', $message);
$this->set('pause', $pause); $this->set('pause', $pause);
$this->set('page_title', $message); $this->set('page_title', $message);
$this->render(false, 'flash'); $this->render(false, $layout);
} }
/** /**

View file

@ -721,6 +721,13 @@ class ControllerTest extends CakeTestCase {
$result = str_replace(array("\t", "\r\n", "\n"), "", $result); $result = str_replace(array("\t", "\r\n", "\n"), "", $result);
$expected = str_replace(array("\t", "\r\n", "\n"), "", $expected); $expected = str_replace(array("\t", "\r\n", "\n"), "", $expected);
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
App::build(array('views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS)));
$Controller =& new Controller();
$Controller->flash('this should work', '/flash', 1, 'ajax2');
$result = $Controller->output;
$this->assertPattern('/Ajax!/', $result);
App::build();
} }
/** /**