diff options
-rw-r--r-- | core/config/routes.php | 4 | ||||
-rw-r--r-- | core/controllers/album.php | 2 | ||||
-rw-r--r-- | core/controllers/item.php | 8 | ||||
-rw-r--r-- | core/controllers/photo.php | 2 | ||||
-rw-r--r-- | core/controllers/rest.php | 24 |
5 files changed, 19 insertions, 21 deletions
diff --git a/core/config/routes.php b/core/config/routes.php index 9b958df1..24e2d73c 100644 --- a/core/config/routes.php +++ b/core/config/routes.php @@ -20,12 +20,10 @@ // REST configuration // Any resource requests (eg: album/1 or comment/3) get dispatched to the REST -// dispatcher. Any direct calls to REST methods are also forced into the dispatcher -// since the REST methods are internally expecting an ORM, not an id. +// dispatcher, and the abstract REST_Controller is not directly routable. $config['^rest'] = null; $config['^rest/.*'] = null; $config['^(\w+)/(\d+)$'] = '$1/dispatch/$2'; -$config['^(\w+)/(?:get|post|put|delete)/(\d+)$'] = '$1/dispatch/$2'; // For now our default page is the scaffolding. $config['_default'] = 'welcome'; diff --git a/core/controllers/album.php b/core/controllers/album.php index cafd6bde..9357c986 100644 --- a/core/controllers/album.php +++ b/core/controllers/album.php @@ -19,7 +19,7 @@ */ class Album_Controller extends Item_Controller { - public function get($item) { + public function _get($item) { // @todo: these need to be pulled from the database $theme_name = "default"; $page_size = 9; diff --git a/core/controllers/item.php b/core/controllers/item.php index 9408af1a..9eb06ad1 100644 --- a/core/controllers/item.php +++ b/core/controllers/item.php @@ -20,14 +20,14 @@ class Item_Controller extends REST_Controller { protected $resource_type = "item"; - public function get($item) { + public function _get($item) { // Redirect to the more specific resource type, since it will render // differently. We could also just delegate here, but it feels more appropriate // to have a single canonical resource mapping. return url::redirect("{$item->type}/$item->id"); } - public function put($item) { + public function _put($item) { // @todo Productionize this code // 1) Add security checks // 2) Support owner_ids properly @@ -70,7 +70,7 @@ class Item_Controller extends REST_Controller { } } - public function delete($item) { + public function _delete($item) { // @todo Production this code // 1) Add security checks $parent = $item->parent(); @@ -80,7 +80,7 @@ class Item_Controller extends REST_Controller { url::redirect("{$parent->type}/{$parent->id}"); } - public function post($item) { + public function _post($item) { // @todo Productionize this // 1) Figure out how to do the right validation here. Validate the form input and apply it to // the model as appropriate. diff --git a/core/controllers/photo.php b/core/controllers/photo.php index 12d86cc4..b56c29b9 100644 --- a/core/controllers/photo.php +++ b/core/controllers/photo.php @@ -19,7 +19,7 @@ */ class Photo_Controller extends Item_Controller { - public function get($item) { + public function _get($item) { $template = new View("page.html"); // @todo: this needs to be data-driven diff --git a/core/controllers/rest.php b/core/controllers/rest.php index 33b0984d..f307f86a 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) { * // Handle GET request * } * - * public function put(ORM $comment) { + * public function _put(ORM $comment) { * // Handle PUT request * } * - * public function post(ORM $comment) { + * public function _post(ORM $comment) { * // Handle POST request * } * - * public function delete(ORM $comment) { + * public function _delete(ORM $comment) { * // Handle DELETE request * } * } @@ -65,7 +65,7 @@ abstract class REST_Controller extends Controller { * PUT/DELETE through POST. */ if (request::method() == "get") { - $this->get($resource); + $this->_get($resource); if (Session::instance()->get("use_profiler", false)) { $profiler = new Profiler(); @@ -76,13 +76,13 @@ abstract class REST_Controller extends Controller { switch ($this->input->post("__action")) { case "put": - return $this->put($resource); + return $this->_put($resource); case "delete": - return $this->delete($resource); + return $this->_delete($resource); default: - return $this->post($resource); + return $this->_post($resource); } } @@ -90,23 +90,23 @@ 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); /** * Perform a PUT request on this resource * @param ORM $resource the instance of this resource type */ - abstract public function put($resource); + abstract public function _put($resource); /** * Perform a POST request on this resource * @param ORM $resource the instance of this resource type */ - abstract public function post($resource); + abstract public function _post($resource); /** * Perform a DELETE request on this resource * @param ORM $resource the instance of this resource type */ - abstract public function delete($resource); + abstract public function _delete($resource); } |