mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
APICHANGE: refactored methods in session to use coding conventions
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@105756 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
83a433894a
commit
eecac2f069
@ -66,7 +66,19 @@ class Session {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 2.5 Use Session::add_to_array($name, $val) instead
|
||||
*/
|
||||
public static function addToArray($name, $val) {
|
||||
user_error('Session::addToArray() is deprecated. Please use Session::add_to_array() instead.', E_USER_NOTICE);
|
||||
|
||||
return Session::add_to_array($name, $val);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a value to a specific key in the session array
|
||||
*/
|
||||
public static function add_to_array($name, $val) {
|
||||
return Controller::curr()->getSession()->inst_addToArray($name, $val);
|
||||
}
|
||||
|
||||
@ -91,9 +103,20 @@ class Session {
|
||||
|
||||
/**
|
||||
* Return all the values in session
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public static function get_all() {
|
||||
return Controller::curr()->getSession()->inst_getAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 2.5 Use Session::get_all()
|
||||
*/
|
||||
public static function getAll() {
|
||||
return Controller::curr()->getSession()->inst_getAll();
|
||||
user_error('Session::getAll() is deprecated. Please use Session::get_all() instead.', E_USER_NOTICE);
|
||||
|
||||
return Session::get_all();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -108,10 +131,19 @@ class Session {
|
||||
/**
|
||||
* Clear all the values
|
||||
*/
|
||||
public static function clearAll() {
|
||||
public static function clear_all() {
|
||||
return Controller::curr()->getSession()->inst_clearAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 2.5 Use Session::clear_all()
|
||||
*/
|
||||
public static function clearAll() {
|
||||
user_error('Session::clearAll() is deprecated. Please use Session::clear_all() instead.', E_USER_NOTICE);
|
||||
|
||||
return Session::clear_all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save all the values in our session to $_SESSION
|
||||
*/
|
||||
|
@ -358,7 +358,7 @@ class Form extends RequestHandler {
|
||||
* and used the next time this form is displayed.
|
||||
*/
|
||||
function addErrorMessage($fieldName, $message, $messageType) {
|
||||
Session::addToArray("FormInfo.{$this->FormName()}.errors", array(
|
||||
Session::add_to_array("FormInfo.{$this->FormName()}.errors", array(
|
||||
'fieldName' => $fieldName,
|
||||
'message' => $message,
|
||||
'messageType' => $messageType,
|
||||
|
@ -26,7 +26,7 @@ class SessionTest extends SapphireTest {
|
||||
Session::set('Test', 'Test');
|
||||
Session::set('Test-1', 'Test-1');
|
||||
|
||||
Session::clearAll();
|
||||
Session::clear_all();
|
||||
|
||||
// should session get return null? The array key should probably be
|
||||
// unset from the data array
|
||||
@ -38,7 +38,7 @@ class SessionTest extends SapphireTest {
|
||||
Session::set('Test', 'Test');
|
||||
Session::set('Test-2', 'Test-2');
|
||||
|
||||
$session = Session::getAll();
|
||||
$session = Session::get_all();
|
||||
|
||||
$this->assertEquals($session, array('Test' => 'Test', 'Test-2' => 'Test-2'));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user