Skip to content

Commit e6c111c

Browse files
committed
Document::getAll() method: Implemented optionally returning internal attributes in addition to the normal attributes
Signed-off-by: Frank Mayer <frank@frankmayer.net>
1 parent 2fc4c1f commit e6c111c

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

lib/triagens/ArangoDb/Document.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,22 @@ public function __get($key) {
204204
/**
205205
* Get all document attributes
206206
*
207+
* @param boolean $includeInternals - true to include the internal attributes. Defaults to false
207208
* @return array - array of all document attributes/values
208209
*/
209-
public function getAll() {
210-
return $this->_values;
210+
public function getAll($includeInternals=false) {
211+
$data=$this->_values;
212+
$nonInternals=array('_changed', '_values');
213+
if ($includeInternals == true) {
214+
foreach ($this as $key => $value) {
215+
if (substr($key,0,1) == '_' && substr($key,0,2) !== '__' && !in_array($key, $nonInternals)) {
216+
217+
$data[$key] = $value;
218+
219+
}
220+
}
221+
}
222+
return $data;
211223
}
212224

213225
/**

0 commit comments

Comments
 (0)