Skip to content
Permalink
Browse files

Updating session component, to not use layout, and use elements instead.

Tests updated.
  • Loading branch information...
markstory committed Sep 1, 2009
1 parent 1bedd84 commit 17e81ab3464036a08b9f753ad9c7c7739dad9277
@@ -1,8 +1,6 @@
<?php
/**
* Short description for file.
*
* Long description for file
* SessionComponent. Provides access to Sessions from the Controller layer
*
* PHP versions 4 and 5
*
@@ -231,15 +229,15 @@ function error() {
* Additional params below can be passed to customize the output, or the Message.[key]
*
* @param string $message Message to be flashed
* @param string $layout Layout to wrap flash message in
* @param string $element Element to wrap flash message in.
* @param array $params Parameters to be sent to layout as view variables
* @param string $key Message key, default is 'flash'
* @access public
*/
function setFlash($message, $layout = 'default', $params = array(), $key = 'flash') {
function setFlash($message, $element = 'default', $params = array(), $key = 'flash') {
if ($this->__active === true) {
$this->__start();
$this->write('Message.' . $key, compact('message', 'layout', 'params'));
$this->write('Message.' . $key, compact('message', 'element', 'params'));
}
}
@@ -324,16 +324,16 @@ function testSessionFlash() {
$this->assertNull($Session->read('Message.flash'));
$Session->setFlash('This is a test message');
$this->assertEqual($Session->read('Message.flash'), array('message' => 'This is a test message', 'layout' => 'default', 'params' => array()));
$this->assertEqual($Session->read('Message.flash'), array('message' => 'This is a test message', 'element' => 'default', 'params' => array()));
$Session->setFlash('This is a test message', 'test', array('name' => 'Joel Moss'));
$this->assertEqual($Session->read('Message.flash'), array('message' => 'This is a test message', 'layout' => 'test', 'params' => array('name' => 'Joel Moss')));
$this->assertEqual($Session->read('Message.flash'), array('message' => 'This is a test message', 'element' => 'test', 'params' => array('name' => 'Joel Moss')));
$Session->setFlash('This is a test message', 'default', array(), 'myFlash');
$this->assertEqual($Session->read('Message.myFlash'), array('message' => 'This is a test message', 'layout' => 'default', 'params' => array()));
$this->assertEqual($Session->read('Message.myFlash'), array('message' => 'This is a test message', 'element' => 'default', 'params' => array()));
$Session->setFlash('This is a test message', 'non_existing_layout');
$this->assertEqual($Session->read('Message.myFlash'), array('message' => 'This is a test message', 'layout' => 'default', 'params' => array()));
$this->assertEqual($Session->read('Message.myFlash'), array('message' => 'This is a test message', 'element' => 'default', 'params' => array()));
$Session->delete('Message');
}

0 comments on commit 17e81ab

Please sign in to comment.
You can’t perform that action at this time.