Add REST support for comments. You can view, add, edit and delete

comments.
This commit is contained in:
Bharat Mediratta
2010-06-16 18:05:15 -07:00
parent bd496cc95c
commit 1aeaa7daab
4 changed files with 213 additions and 0 deletions
+16
View File
@@ -175,4 +175,20 @@ class Comment_Model extends ORM {
static function valid_state($value) {
return in_array($value, array("published", "unpublished", "spam", "deleted"));
}
/**
* Same as ORM::as_array() but convert id fields into their RESTful form.
*/
public function as_restful_array() {
$data = array();
foreach ($this->as_array() as $key => $value) {
if (strncmp($key, "server_", 7)) {
$data[$key] = $value;
}
}
$data["item"] = rest::url("item", $this->item());
unset($data["item_id"]);
return $data;
}
}