summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2010-01-04 21:48:21 -0800
committerBharat Mediratta <bharat@menalto.com>2010-01-04 21:48:21 -0800
commit3fffa18e650189e7f846592c9d4c3e7bbfe71c62 (patch)
tree4800f553d249fd2908a457aa6bd1dcd394223fec /modules/gallery/helpers
parent0e3327bca70623175791ee41085d55d0cb13fe5b (diff)
Further progress on refining the REST server side code.
1) Deal in fully qualified URL resources through the rest interface. All rest methods are now passed the complete url in request->url. 2) Create rest::resolve() which lets individual resource definition code convert a full url into the appropriate matching resource. Implement gallery_rest::resolve() and tag_rest::resolve() 3) Reimplement tag_rest's get() and post() methods. They're much simpler now. 4) Implement the tags_rest helper which supports working with the entire tags collection.
Diffstat (limited to 'modules/gallery/helpers')
-rw-r--r--modules/gallery/helpers/gallery_rest.php14
1 files changed, 9 insertions, 5 deletions
diff --git a/modules/gallery/helpers/gallery_rest.php b/modules/gallery/helpers/gallery_rest.php
index f1c8d825..858721d0 100644
--- a/modules/gallery/helpers/gallery_rest.php
+++ b/modules/gallery/helpers/gallery_rest.php
@@ -37,14 +37,14 @@
class gallery_rest_Core {
static function get($request) {
- $item = url::get_item_from_uri($request->path);
+ $item = rest::resolve($request->url);
access::required("view", $item);
- return json_encode($item->as_array());
+ return rest::reply($item->as_array());
}
static function put($request) {
- $item = url::get_item_from_uri($request->path);
+ $item = rest::resolve($request->url);
access::required("edit", $item);
$params = $request->params;
@@ -60,7 +60,7 @@ class gallery_rest_Core {
}
static function post($request) {
- $parent = url::get_item_from_uri($request->path);
+ $parent = rest::resolve($request->url);
access::required("edit", $parent);
$params = $request->params;
@@ -90,10 +90,14 @@ class gallery_rest_Core {
}
static function delete($request) {
- $item = url::get_item_from_uri($request->path);
+ $item = rest::resolve($request->url);
access::required("edit", $item);
$item->delete();
return rest::reply();
}
+
+ static function resolve($path) {
+ return url::get_item_from_uri($path);
+ }
}