mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Updating session component, to not use layout, and use elements instead.
Tests updated.
This commit is contained in:
parent
1bedd8418b
commit
17e81ab346
2 changed files with 8 additions and 10 deletions
|
@ -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 @@ class SessionComponent extends CakeSession {
|
|||
* 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 @@ class SessionComponentTest extends CakeTestCase {
|
|||
$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');
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue