Browse Source

Change flash session variable from Message to Flash

Bryan Crowe 11 years ago
parent
commit
795eb4d04f

+ 2 - 2
src/Controller/Component/FlashComponent.php

@@ -63,7 +63,7 @@ class FlashComponent extends Component {
  *
  * ### Options:
  *
- * - `key` The key to set under the session's Message key
+ * - `key` The key to set under the session's Flash key
  * - `element` The element used to render the flash message
  * - `params` An array of variables to make available when using an element
  *
@@ -78,7 +78,7 @@ class FlashComponent extends Component {
 			$message = $message->getMessage();
 		}
 
-		$this->_session->write("Message.{$opts['key']}", [
+		$this->_session->write("Flash.{$opts['key']}", [
 			'message' => $message,
 			'key' => $opts['key'],
 			'element' => $opts['element'],

+ 3 - 3
src/View/Helper/FlashHelper.php

@@ -58,14 +58,14 @@ class FlashHelper extends Helper {
  * ]);
  * }}}
  *
- * @param string $key The [Message.]key you are rendering in the view.
+ * @param string $key The [Flash.]key you are rendering in the view.
  * @param array $options Additional options to use for the creation of this flash message.
  *    Supports the 'params', and 'element' keys that are used in the helper.
  * @return string
  */
 	public function render($key = 'flash', array $options = []) {
-		$flash = $this->request->session()->read("Message.$key");
-		$this->request->session()->delete("Message.$key");
+		$flash = $this->request->session()->read("Flash.$key");
+		$this->request->session()->delete("Flash.$key");
 
 		if (!$flash) {
 			return '';

+ 7 - 7
tests/TestCase/Controller/Component/FlashComponentTest.php

@@ -60,7 +60,7 @@ class FlashComponentTest extends TestCase {
  * @covers \Cake\Controller\Component\FlashComponent::set
  */
 	public function testSet() {
-		$this->assertNull($this->Session->read('Message.flash'));
+		$this->assertNull($this->Session->read('Flash.flash'));
 
 		$this->Flash->set('This is a test message');
 		$expected = [
@@ -69,7 +69,7 @@ class FlashComponentTest extends TestCase {
 			'element' => null,
 			'params' => []
 		];
-		$result = $this->Session->read('Message.flash');
+		$result = $this->Session->read('Flash.flash');
 		$this->assertEquals($expected, $result);
 
 		$this->Flash->set('This is a test message', ['element' => 'test', 'params' => ['foo' => 'bar']]);
@@ -79,7 +79,7 @@ class FlashComponentTest extends TestCase {
 			'element' => 'test',
 			'params' => ['foo' => 'bar']
 		];
-		$result = $this->Session->read('Message.flash');
+		$result = $this->Session->read('Flash.flash');
 		$this->assertEquals($expected, $result);
 
 		$this->Flash->set('This is a test message', ['element' => 'MyPlugin.alert']);
@@ -89,7 +89,7 @@ class FlashComponentTest extends TestCase {
 			'element' => 'MyPlugin.alert',
 			'params' => []
 		];
-		$result = $this->Session->read('Message.flash');
+		$result = $this->Session->read('Flash.flash');
 		$this->assertEquals($expected, $result);
 
 		$this->Flash->set('This is a test message', ['key' => 'foobar']);
@@ -99,7 +99,7 @@ class FlashComponentTest extends TestCase {
 			'element' => null,
 			'params' => []
 		];
-		$result = $this->Session->read('Message.foobar');
+		$result = $this->Session->read('Flash.foobar');
 		$this->assertEquals($expected, $result);
 	}
 
@@ -110,7 +110,7 @@ class FlashComponentTest extends TestCase {
  * @covers \Cake\Controller\Component\FlashComponent::set
  */
 	public function testSetWithException() {
-		$this->assertNull($this->Session->read('Message.flash'));
+		$this->assertNull($this->Session->read('Flash.flash'));
 
 		$this->Flash->set(new \Exception('This is a test message'));
 		$expected = [
@@ -119,7 +119,7 @@ class FlashComponentTest extends TestCase {
 			'element' => null,
 			'params' => []
 		];
-		$result = $this->Session->read('Message.flash');
+		$result = $this->Session->read('Flash.flash');
 		$this->assertEquals($expected, $result);
 	}
 }

+ 1 - 1
tests/TestCase/View/Helper/FlashHelperTest.php

@@ -42,7 +42,7 @@ class FlashHelperTest extends TestCase {
 		$this->Flash = new FlashHelper($this->View);
 
 		$session->write(array(
-			'Message' => array(
+			'Flash' => array(
 				'flash' => array(
 					'key' => 'flash',
 					'message' => 'This is a calling',