diff options
author | Bharat Mediratta <bharat@menalto.com> | 2008-12-25 05:12:46 +0000 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2008-12-25 05:12:46 +0000 |
commit | fdc0f83024ee8a10f223132d9e02a9e10466e46a (patch) | |
tree | 38dc87629f8063ac3997edbd2a852c318ffb089f /core/controllers/rest.php | |
parent | 6e68c5ca28e52773fca16e77aecdde2b92351af2 (diff) |
Big round of normalization of the way that our controllers
communicate. Almost all controllers now use JSON to speak to the
theme when we're dealing with form processing. This means tht we only
send the form back and forth, but we use a JSON protocol to tell the
browser success/error status as well as the location of any newly
created resources, or where the browser should redirect the user.
Lots of small changes:
1) Admin -> Edit Profile is gone. Instead I fixed the "Modify Profile" link
in the top right corner to be a modal dialog
2) We use json_encode everywhere. No more Atom/XML for now. We can bring those
back later, though. For now there's a lot of code duplication but that'll be
easy to clean up.
3) REST_Controller is no longer abstract. All methods its subclasses should create
throw exceptions, which means that subclasses don't have to implement stubs for
those methods.
4) New pattern: helper method get_add_form calls take an Item_Model,
not an id since we have to load the Item_Model in the controller
anyway to check permissions.
5) User/Groups REST resources are separate from User/Group in the site
admin. They do different things, we should avoid confusing overlap.
Diffstat (limited to 'core/controllers/rest.php')
-rw-r--r-- | core/controllers/rest.php | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/core/controllers/rest.php b/core/controllers/rest.php index 0ac7a1c9..ceca321e 100644 --- a/core/controllers/rest.php +++ b/core/controllers/rest.php @@ -55,11 +55,11 @@ * } * * A request to http://example.com/gallery3/comments/3 will result in a call to - * REST_Controller::dispatch(3) which will load up the comment associated with id 3. If there's + * REST_Controller::__call(3) which will load up the comment associated with id 3. If there's * no such comment, it returns a 404. Otherwise, it will then delegate to * Comment_Controller::get() with the ORM instance as an argument. */ -abstract class REST_Controller extends Controller { +class REST_Controller extends Controller { protected $resource_type = null; public function __construct() { @@ -125,41 +125,55 @@ abstract class REST_Controller extends Controller { * Perform a GET request on the controller root * (e.g. http://www.example.com/gallery3/comments) */ - abstract public function _index(); + public function _index() { + throw new Exception("@todo _create NOT IMPLEMENTED"); + } /** * Perform a POST request on this resource * @param ORM $resource the instance of this resource type */ - abstract public function _create($resource); + public function _create($resource) { + throw new Exception("@todo _create NOT IMPLEMENTED"); + } /** * Perform a GET request on this resource * @param ORM $resource the instance of this resource type */ - abstract public function _show($resource); + public function _show($resource) { + throw new Exception("@todo _show NOT IMPLEMENTED"); + } /** * Perform a PUT request on this resource * @param ORM $resource the instance of this resource type */ - abstract public function _update($resource); + public function _update($resource) { + throw new Exception("@todo _update NOT IMPLEMENTED"); + } /** * Perform a DELETE request on this resource * @param ORM $resource the instance of this resource type */ - abstract public function _delete($resource); + public function _delete($resource) { + throw new Exception("@todo _delete NOT IMPLEMENTED"); + } /** * Present a form for adding a new resource * @param string part of the URI after the controller name */ - abstract public function _form_add($parameter); + public function _form_add($parameter) { + throw new Exception("@todo _form_add NOT IMPLEMENTED"); + } /** * Present a form for editing an existing resource * @param ORM $resource the resource container for instances of this resource type */ - abstract public function _form_edit($resource); + public function _form_edit($resource) { + throw new Exception("@todo _form_edit NOT IMPLEMENTED"); + } } |