summaryrefslogtreecommitdiff
path: root/program/lib/Roundcube
diff options
context:
space:
mode:
authorThomas Bruederli <thomas@roundcube.net>2014-03-06 13:13:01 +0100
committerThomas Bruederli <thomas@roundcube.net>2014-04-03 17:58:49 +0200
commit2f43fe94cb02edcb124ce30f29d165ea09478a18 (patch)
treeface8dbb617dec8b79f9c23a563d70224a8ecb3a /program/lib/Roundcube
parent56be9c50ead9135d8f637b89cef8781e8423ec28 (diff)
Implement ArrayAccess interface for conveniently accessing rcube_result_set as array
Diffstat (limited to 'program/lib/Roundcube')
-rw-r--r--program/lib/Roundcube/rcube_result_set.php30
1 files changed, 29 insertions, 1 deletions
diff --git a/program/lib/Roundcube/rcube_result_set.php b/program/lib/Roundcube/rcube_result_set.php
index a4b070e28..82502ce5f 100644
--- a/program/lib/Roundcube/rcube_result_set.php
+++ b/program/lib/Roundcube/rcube_result_set.php
@@ -25,7 +25,7 @@
* @package Framework
* @subpackage Addressbook
*/
-class rcube_result_set implements Iterator
+class rcube_result_set implements Iterator, ArrayAccess
{
public $count = 0;
public $first = 0;
@@ -61,6 +61,34 @@ class rcube_result_set implements Iterator
$this->current = $i;
}
+ /*** Implement PHP ArrayAccess interface ***/
+
+ public function offsetSet($offset, $value)
+ {
+ if (is_null($offset)) {
+ $offset = count($this->records);
+ $this->records[] = $value;
+ }
+ else {
+ $this->records[$offset] = $value;
+ }
+ }
+
+ public function offsetExists($offset)
+ {
+ return isset($this->records[$offset]);
+ }
+
+ public function offsetUnset($offset)
+ {
+ unset($this->records[$offset]);
+ }
+
+ public function offsetGet($offset)
+ {
+ return $this->records[$offset];
+ }
+
/*** PHP 5 Iterator interface ***/
function rewind()