Add ArrayAccess implementation for Horde_Prefs
authorMichael M Slusarz <slusarz@curecanti.org>
Mon, 11 Oct 2010 04:51:58 +0000 (22:51 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 12 Oct 2010 20:31:24 +0000 (14:31 -0600)
framework/Prefs/lib/Horde/Prefs.php
framework/Prefs/package.xml

index a653504..9282f0a 100644 (file)
@@ -13,7 +13,7 @@
  * @category Horde
  * @package  Prefs
  */
-class Horde_Prefs
+class Horde_Prefs implements ArrayAccess
 {
     /** Preference is administratively locked. */
     const LOCKED = 1;
@@ -807,4 +807,26 @@ class Horde_Prefs
         }
     }
 
+    /* ArrayAccess methods. */
+
+    public function offsetExists($offset)
+    {
+        return !is_null($this->getValue($offset));
+    }
+
+    public function offsetGet($offset)
+    {
+        return $this->getValue($offset);
+    }
+
+    public function offsetSet($offset, $value)
+    {
+        $this->setValue($offset, $value);
+    }
+
+    public function offsetUnset($offset)
+    {
+        $this->remove($offset);
+    }
+
 }
index ce6e50f..f027999 100644 (file)
@@ -24,7 +24,8 @@ http://pear.php.net/dtd/package-2.0.xsd">
   <api>beta</api>
  </stability>
  <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>* Remove dependency on horde/Core.
+ <notes>* Add array access API to Horde_Prefs.
+ * Remove dependency on horde/Core.
  * Use Horde_Db as backend for Sql driver.
  * Moved UI code to horde/Core.
  * Initial Horde 4 package.