summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2008-12-26 01:29:33 +0000
committerBharat Mediratta <bharat@menalto.com>2008-12-26 01:29:33 +0000
commiteb35afc987a4e8b2772d10ac2bd63b1a3a091239 (patch)
tree3500f3a1eccc131b9e263e04068bd4485b8991b1
parent7f95c80e8897babcadac270ee5884963a734e1bc (diff)
Add module::clear_var()
-rw-r--r--core/helpers/module.php15
-rw-r--r--core/tests/Var_Test.php8
2 files changed, 23 insertions, 0 deletions
diff --git a/core/helpers/module.php b/core/helpers/module.php
index 415ecf4b..321a33fa 100644
--- a/core/helpers/module.php
+++ b/core/helpers/module.php
@@ -243,4 +243,19 @@ class module_Core {
$var->value = $value;
$var->save();
}
+
+ /**
+ * Remove a variable for this module.
+ * @param string $module_name
+ * @param string $name
+ */
+ public function clear_var($module_name, $name) {
+ $var = ORM::factory("var")
+ ->where("module_name", $module_name)
+ ->where("name", $name)
+ ->find();
+ if ($var->loaded) {
+ $var->delete();
+ }
+ }
}
diff --git a/core/tests/Var_Test.php b/core/tests/Var_Test.php
index e186a7c2..de07ba52 100644
--- a/core/tests/Var_Test.php
+++ b/core/tests/Var_Test.php
@@ -25,4 +25,12 @@ class Var_Test extends Unit_Test_Case {
module::set_var("core", "Parameter", "updated value");
$this->assert_equal("updated value", module::get_var("core", "Parameter"));
}
+
+ public function clear_parameter_test() {
+ module::set_var("core", "Parameter", "original value");
+ $this->assert_equal("original value", module::get_var("core", "Parameter"));
+
+ module::clear_var("core", "Parameter");
+ $this->assert_equal(null, module::get_var("core", "Parameter"));
+ }
} \ No newline at end of file