summaryrefslogtreecommitdiff
path: root/core/controllers/rest.php
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2008-11-17 00:30:18 +0000
committerBharat Mediratta <bharat@menalto.com>2008-11-17 00:30:18 +0000
commitc91e90406bbc81f8311a1d2707dd141d150f99a4 (patch)
treeddda2c6bacd4b0e0e30f4c8a62d13b2842b864cc /core/controllers/rest.php
parent0975e702a99dad701f66c606de6597048338f247 (diff)
Add output formats to our REST controllers. Add support for JSON and
XML to the comment controllers as a proof of concept. It's not fully baked; we should examine ways to create helpers to make this process easier.
Diffstat (limited to 'core/controllers/rest.php')
-rw-r--r--core/controllers/rest.php13
1 files changed, 7 insertions, 6 deletions
diff --git a/core/controllers/rest.php b/core/controllers/rest.php
index 82262f3b..3b630f2d 100644
--- a/core/controllers/rest.php
+++ b/core/controllers/rest.php
@@ -24,19 +24,19 @@
* class Comment_Controller extends REST_Controller {
* protected $resource_type = "comment"; // this tells REST which model to use
*
- * public function _get(ORM $comment) {
+ * public function _get(ORM $comment, $output_format) {
* // Handle GET request
* }
*
- * public function _put(ORM $comment) {
+ * public function _put(ORM $comment, $output_format) {
* // Handle PUT request
* }
*
- * public function _post(ORM $comment) {
+ * public function _post(ORM $comment, $output_format) {
* // Handle POST request
* }
*
- * public function _delete(ORM $comment) {
+ * public function _delete(ORM $comment, $output_format) {
* // Handle DELETE request
* }
*
@@ -67,8 +67,9 @@ abstract class REST_Controller extends Controller {
* We're expecting to run in an environment that only supports GET/POST, so expect to tunnel
* PUT/DELETE through POST.
*/
+ $output_format = $this->input->get("_format", $this->input->post("_format", "html"));
if (request::method() == "get") {
- $this->_get($resource);
+ $this->_get($resource, $output_format);
if (Session::instance()->get("use_profiler", false)) {
$profiler = new Profiler();
@@ -107,7 +108,7 @@ abstract class REST_Controller extends Controller {
* Perform a GET request on this resource
* @param ORM $resource the instance of this resource type
*/
- abstract public function _get($resource);
+ abstract public function _get($resource, $output_format);
/**
* Perform a PUT request on this resource