summaryrefslogtreecommitdiff
path: root/core/controllers/rest.php
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2008-11-14 16:51:11 +0000
committerTim Almdal <tnalmdal@shaw.ca>2008-11-14 16:51:11 +0000
commite0ec9dd76a62ad712b2a771a383f262557116753 (patch)
treee9cbee80da6f8a2df2e2833e3b9d4f4000908aac /core/controllers/rest.php
parent5a2fe6bb0b3068c47337e7382354f8ca340375e2 (diff)
Allow the HTTP get method to be called without an id to create any empty template.
Diffstat (limited to 'core/controllers/rest.php')
-rw-r--r--core/controllers/rest.php18
1 files changed, 13 insertions, 5 deletions
diff --git a/core/controllers/rest.php b/core/controllers/rest.php
index ff4d5120..6e0acbcb 100644
--- a/core/controllers/rest.php
+++ b/core/controllers/rest.php
@@ -49,17 +49,25 @@
abstract class REST_Controller extends Controller {
protected $resource_type = null;
- public function dispatch($id) {
+ public function dispatch($id=null) {
if ($this->resource_type == null) {
throw new Exception("@todo ERROR_MISSING_RESOURCE_TYPE");
}
- // @todo this needs security checks
- $resource = ORM::factory($this->resource_type, $id);
- if (!$resource->loaded) {
+ if ($id != null) {
+ // @todo this needs security checks
+ $resource = ORM::factory($this->resource_type, $id);
+ if (!$resource->loaded) {
+ return Kohana::show_404();
+ }
+ } else if (request::method() == "get") {
+ // A null id and a request method of "get" just returns an empty form
+ // @todo figure out how to handle the input without and id
+ // @todo do we use put for create and post for update?
+ $resource = null;
+ } else {
return Kohana::show_404();
}
-
/**
* We're expecting to run in an environment that only supports GET/POST, so expect to tunnel
* PUT/DELETE through POST.