summaryrefslogtreecommitdiff
path: root/modules/gallery/models/item.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery/models/item.php')
-rw-r--r--modules/gallery/models/item.php17
1 files changed, 17 insertions, 0 deletions
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php
index ae6e4cc9..fd121a5a 100644
--- a/modules/gallery/models/item.php
+++ b/modules/gallery/models/item.php
@@ -914,4 +914,21 @@ class Item_Model extends ORM_MPTT {
$v->add_error($field, "read_only");
}
}
+
+ /**
+ * Same as ORM::as_array() but convert id fields into their RESTful form.
+ */
+ public function as_restful_array() {
+ // Convert item ids to rest URLs for consistency
+ $data = $this->as_array();
+ if ($tmp = $this->parent()) {
+ $data["parent"] = rest::url("item", $tmp);
+ }
+ unset($data["parent_id"]);
+ if ($tmp = $this->album_cover()) {
+ $data["album_cover"] = rest::url("item", $tmp);
+ }
+ unset($data["album_cover_item_id"]);
+ return $data;
+ }
}