Permalink
Browse files

feature(widgets): added unset on \ElggWidget objects to remove settings

  • Loading branch information...
jdalsem committed Mar 23, 2016
1 parent 64aa291 commit f99e4f5debea861aede1e3009b11f07f917b0b06
Showing with 20 additions and 2 deletions.
  1. +20 −2 engine/classes/ElggWidget.php
@@ -28,7 +28,7 @@ protected function initializeAttributes() {
/**
* Get a value from attributes or private settings
- *
+ *
* @param string $name The name of the value
* @return mixed
*/
@@ -63,7 +63,7 @@ public function get($name) {
/**
* Set an attribute or private setting value
- *
+ *
* @param string $name The name of the value to set
* @param mixed $value The value to set
* @return void
@@ -95,6 +95,24 @@ public function set($name, $value) {
return true;
}
+
+ /**
+ * Unset a property from private settings or attribute.
+ *
+ * @see \ElggEntity->__unset
+ *
+ * @param string $name The name of the attribute or metadata.
+ *
+ * @return void
+ * @since 2.2.0
+ */
+ public function __unset($name) {
+ if (array_key_exists($name, $this->attributes)) {
+ parent::__unset($name);
+ } else {
+ $this->removePrivateSetting($name);
+ }
+ }
/**
* Set the widget context

0 comments on commit f99e4f5

Please sign in to comment.