Skip to content
Browse files

Add two public method delete_var and clean_var to fixing issue #514

  • Loading branch information...
1 parent 73b295c commit 5eafe057007a44734d52b9f2693f55488e4fc249 @appleboy committed Sep 30, 2011
Showing with 42 additions and 2 deletions.
  1. +42 −2 system/core/Loader.php
View
44 system/core/Loader.php
@@ -472,7 +472,7 @@ public function vars($vars = array(), $val = '')
*
* Check if a variable is set and retrieve it.
*
- * @param array
+ * @param string
* @return void
*/
public function get_var($key)
@@ -483,6 +483,46 @@ public function get_var($key)
// --------------------------------------------------------------------
/**
+ * Delete Variable
+ *
+ * Delete if a variable is set and retrieve it.
+ *
+ * @param mixed
+ * @return void
+ */
+ public function delete_var($vars = array())
+ {
+ if ($vars != '' AND is_string($vars))
+ {
+ unset($this->_ci_cached_vars[$vars]);
+ }
+
+ if (is_array($vars) AND count($vars) > 0)
+ {
+ foreach ($vars as $key)
+ {
+ unset($this->_ci_cached_vars[$key]);
+ }
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Clean Variable
+ *
+ * Clean all cached variables.
+ *
+ * @return void
+ */
+ public function clean_var()
+ {
+ $this->_ci_cached_vars = array();
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Load Helper
*
* This function loads the specified helper file.
@@ -1240,4 +1280,4 @@ protected function _ci_prep_filename($filename, $extension)
}
/* End of file Loader.php */
-/* Location: ./system/core/Loader.php */
+/* Location: ./system/core/Loader.php */

0 comments on commit 5eafe05

Please sign in to comment.
Something went wrong with that request. Please try again.