Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Closed
wants to merge 1 commit into from

1 participant

@appleboy

I add two public method delete_var and clean_var which can delete or clean cached data on load class.

Fix issue #514

@appleboy appleboy closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
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 */
Something went wrong with that request. Please try again.