diff options
| author | Jozef Selesi <jozefs@users.sourceforge.net> | 2008-11-18 08:28:32 +0000 | 
|---|---|---|
| committer | Jozef Selesi <jozefs@users.sourceforge.net> | 2008-11-18 08:28:32 +0000 | 
| commit | 3ebb751cda5d47147a5c828b4cb32ecd4a9f8042 (patch) | |
| tree | 2394d31d14417f13e8cac72c11b9df01b3c84507 /core/controllers/item.php | |
| parent | 59dbd1dc833a974f55f5cc66fa1c3204fa30980e (diff) | |
First iteration of REST controller refactoring. RESTful controllers that refer to collections should now have plural names and there should be only one controller per resource. Updated existing classes that implement REST_Controller. The routing now works like this:
GET    /controller    -> controller::_index()
POST   /controller    -> controller::_create()
GET    /controller/id -> controller::_show()
PUT    /controller/id -> controller::_update()
DELETE /controller/id -> controller::_delete()
GET    /form/edit/controller/resource_id -> controller::_form()
GET    /form/add/controller/data         -> controller::_form()
Diffstat (limited to 'core/controllers/item.php')
| -rw-r--r-- | core/controllers/item.php | 15 | 
1 files changed, 11 insertions, 4 deletions
| diff --git a/core/controllers/item.php b/core/controllers/item.php index 70af9d95..7ee3674b 100644 --- a/core/controllers/item.php +++ b/core/controllers/item.php @@ -21,20 +21,27 @@ class Item_Controller extends REST_Controller {    protected $resource_type = "item";    /** +   *  @see Rest_Controller::_index($query) +   */ +  public function _index($query) { +    throw new Exception("@todo Item_Controller::_index NOT IMPLEMENTED"); +  } + +  /**     *  @see Rest_Controller::_form($resource)     */ -  public function _form($item) { +  public function _form($item, $form_type) {      throw new Exception("@todo Comment_Controller::_form NOT IMPLEMENTED");    } -  public function _get($item, $format) { +  public function _show($item, $format) {      // 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 _update($item) {      // @todo Productionize this code      // 1) Add security checks      // 2) Support owner_ids properly @@ -92,7 +99,7 @@ class Item_Controller extends REST_Controller {      url::redirect("{$parent->type}/{$parent->id}");    } -  public function _post($item) { +  public function _create($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. | 
