summaryrefslogtreecommitdiff
path: root/modules/user/controllers
diff options
context:
space:
mode:
authorJozef Selesi <jozefs@users.sourceforge.net>2008-11-18 08:28:32 +0000
committerJozef Selesi <jozefs@users.sourceforge.net>2008-11-18 08:28:32 +0000
commit3ebb751cda5d47147a5c828b4cb32ecd4a9f8042 (patch)
tree2394d31d14417f13e8cac72c11b9df01b3c84507 /modules/user/controllers
parent59dbd1dc833a974f55f5cc66fa1c3204fa30980e (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 'modules/user/controllers')
-rw-r--r--modules/user/controllers/users.php46
1 files changed, 29 insertions, 17 deletions
diff --git a/modules/user/controllers/users.php b/modules/user/controllers/users.php
index 5b438de9..ea3a4c8b 100644
--- a/modules/user/controllers/users.php
+++ b/modules/user/controllers/users.php
@@ -21,25 +21,31 @@ class Users_Controller extends REST_Controller {
protected $resource_type = "user";
/**
- * Present a form for editing a user
- * @see Rest_Controller::form($resource)
+ * Display comments based on criteria.
+ * @see Rest_Controller::_delete($resource)
*/
- public function _form($user) {
- $form = user::get_edit_form($user);
- print $form;
+ public function _index($query) {
+ throw new Exception("@todo Comment_Controller::_index NOT IMPLEMENTED");
+ }
+
+ /**
+ * @see Rest_Controller::_create($resource)
+ */
+ public function _create($user) {
+ throw new Exception("@todo User_Controller::_create NOT IMPLEMENTED");
}
/**
- * @see Rest_Controller::_get($resource, $format)
+ * @see Rest_Controller::_show($resource, $format)
*/
- public function _get($user, $format) {
- throw new Exception("@todo User_Controller::_get NOT IMPLEMENTED");
+ public function _show($user, $format) {
+ throw new Exception("@todo User_Controller::_show NOT IMPLEMENTED");
}
/**
- * @see Rest_Controller::_put($resource)
+ * @see Rest_Controller::_update($resource)
*/
- public function _put($user) {
+ public function _update($user) {
$form = user::get_edit_form($user);
if ($form->validate()) {
foreach ($form->as_array() as $key => $value) {
@@ -55,16 +61,22 @@ class Users_Controller extends REST_Controller {
}
/**
- * @see Rest_Controller::_post($resource)
+ * @see Rest_Controller::_delete($resource)
*/
- public function _post($user) {
- throw new Exception("@todo User_Controller::_post NOT IMPLEMENTED");
+ public function _delete($user) {
+ throw new Exception("@todo User_Controller::_delete NOT IMPLEMENTED");
}
/**
- * @see Rest_Controller::_delete($resource)
+ * Present a form for editing a user
+ * @see Rest_Controller::form($resource)
*/
- public function _delete($user) {
- throw new Exception("@todo User_Controller::_delete NOT IMPLEMENTED");
+ public function _form($user, $form_type) {
+ if ($form_type == "edit") {
+ $form = user::get_edit_form($user);
+ print $form;
+ } else {
+ return Kohana::show_404();
+ }
}
-} \ No newline at end of file
+}