diff options
author | Bharat Mediratta <bharat@menalto.com> | 2008-11-11 06:24:30 +0000 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2008-11-11 06:24:30 +0000 |
commit | d35f337b7bc719ed0a4534ca835abbfa46d24a18 (patch) | |
tree | e738bdf4d5f812bf64a69c3fdeb8c1b1acab2c4a | |
parent | 9f261213a5ad8e70dc4ab8ccd9bc76490a58763a (diff) |
Add phpdocs to explain how to use REST_Controller
-rw-r--r-- | core/controllers/rest.php | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/core/controllers/rest.php b/core/controllers/rest.php index 50e4e113..33b0984d 100644 --- a/core/controllers/rest.php +++ b/core/controllers/rest.php @@ -17,6 +17,35 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ +/** + * This abstract controller makes it easy to create a RESTful controller. To use it, create a + * subclass which defines the resource type and implements get/post/put/delete methods, like this: + * + * class Comment_Controller extends REST_Controller { + * protected $resource_type = "comment"; // this tells REST which model to use + * + * public function get(ORM $comment) { + * // Handle GET request + * } + * + * public function put(ORM $comment) { + * // Handle PUT request + * } + * + * public function post(ORM $comment) { + * // Handle POST request + * } + * + * public function delete(ORM $comment) { + * // Handle DELETE request + * } + * } + * + * A request to http://example.com/gallery3/comment/3 will result in a call to + * REST_Controller::dispatch(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 { protected $resource_type = null; |