diff options
author | dchill42 <dchill42@gmail.com> | 2012-11-25 00:41:13 +0100 |
---|---|---|
committer | dchill42 <dchill42@gmail.com> | 2012-11-25 07:30:24 +0100 |
commit | 6262d053db57957c4445ef7fce76070854c3e30d (patch) | |
tree | a57f2693abeeedc91d0f7a539ae55028eff4c541 /system/libraries/Session | |
parent | ad5f1d032fb3204bc1b81891a3231ae8ac47392b (diff) |
Added support for extending individual driver classes and driver unit tests
Signed-off-by: dchill42 <dchill42@gmail.com>
Diffstat (limited to 'system/libraries/Session')
-rw-r--r-- | system/libraries/Session/Session.php | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/system/libraries/Session/Session.php b/system/libraries/Session/Session.php index 96e65f154..b6c862dae 100644 --- a/system/libraries/Session/Session.php +++ b/system/libraries/Session/Session.php @@ -107,17 +107,15 @@ class CI_Session extends CI_Driver_Library { // Get valid drivers list $this->valid_drivers = array( - 'Session_native', - 'Session_cookie' + 'native', + 'cookie' ); $key = 'sess_valid_drivers'; $drivers = isset($params[$key]) ? $params[$key] : $CI->config->item($key); if ($drivers) { - is_array($drivers) OR $drivers = array($drivers); - // Add driver names to valid list - foreach ($drivers as $driver) + foreach ((array) $drivers as $driver) { if ( ! in_array(strtolower($driver), array_map('strtolower', $this->valid_drivers))) { @@ -134,9 +132,9 @@ class CI_Session extends CI_Driver_Library { $driver = 'cookie'; } - if ( ! in_array('session_'.strtolower($driver), array_map('strtolower', $this->valid_drivers))) + if ( ! in_array(strtolower($driver), array_map('strtolower', $this->valid_drivers))) { - $this->valid_drivers[] = 'Session_'.$driver; + $this->valid_drivers[] = $driver; } // Save a copy of parameters in case drivers need access @@ -178,17 +176,17 @@ class CI_Session extends CI_Driver_Library { /** * Select default session storage driver * - * @param string Driver classname + * @param string Driver name * @return void */ public function select_driver($driver) { // Validate driver name - $lowername = strtolower(str_replace('CI_', '', $driver)); - if (in_array($lowername, array_map('strtolower', $this->valid_drivers))) + $prefix = (string) get_instance()->config->item('subclass_prefix'); + $child = strtolower(str_replace(array('CI_', $prefix, $this->lib_name.'_'), '', $driver)); + if (in_array($child, array_map('strtolower', $this->valid_drivers))) { // See if driver is loaded - $child = str_replace($this->lib_name.'_', '', $driver); if (isset($this->$child)) { // See if driver is already current |