diff options
Diffstat (limited to 'core/controllers')
-rw-r--r-- | core/controllers/album.php | 10 | ||||
-rw-r--r-- | core/controllers/item.php | 7 | ||||
-rw-r--r-- | core/controllers/photo.php | 10 | ||||
-rw-r--r-- | core/controllers/rest.php | 24 |
4 files changed, 51 insertions, 0 deletions
diff --git a/core/controllers/album.php b/core/controllers/album.php index 63290853..87e27ac5 100644 --- a/core/controllers/album.php +++ b/core/controllers/album.php @@ -19,6 +19,16 @@ */ class Album_Controller extends Item_Controller { + /** + * @see Rest_Controller::_form($resource) + */ + public function _form($comment) { + throw new Exception("@todo Comment_Controller::_get NOT IMPLEMENTED"); + } + + /** + * @see Rest_Controller::_get($resource) + */ public function _get($item) { // @todo: these need to be pulled from the database $theme_name = "default"; diff --git a/core/controllers/item.php b/core/controllers/item.php index e9ff03e6..027dcada 100644 --- a/core/controllers/item.php +++ b/core/controllers/item.php @@ -20,6 +20,13 @@ class Item_Controller extends REST_Controller { protected $resource_type = "item"; + /** + * @see Rest_Controller::_form($resource) + */ + public function _form($comment) { + throw new Exception("@todo Comment_Controller::_get NOT IMPLEMENTED"); + } + 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 diff --git a/core/controllers/photo.php b/core/controllers/photo.php index 78287afa..4c3154bd 100644 --- a/core/controllers/photo.php +++ b/core/controllers/photo.php @@ -19,6 +19,16 @@ */ class Photo_Controller extends Item_Controller { + /** + * @see Rest_Controller::_form($resource) + */ + public function _form($comment) { + throw new Exception("@todo Comment_Controller::_get NOT IMPLEMENTED"); + } + + /** + * @see Rest_Controller::_get($resource) + */ public function _get($item) { $template = new View("page.html"); diff --git a/core/controllers/rest.php b/core/controllers/rest.php index 09c85653..4a6c4eb4 100644 --- a/core/controllers/rest.php +++ b/core/controllers/rest.php @@ -39,6 +39,10 @@ * public function _delete(ORM $comment) { * // Handle DELETE request * } + * + * public function form(ORM $comment) { + * // Show a form for creating a new comment + * } * } * * A request to http://example.com/gallery3/comment/3 will result in a call to @@ -85,6 +89,20 @@ abstract class REST_Controller extends Controller { } } + public function form($id) { + if ($this->resource_type == null) { + throw new Exception("@todo ERROR_MISSING_RESOURCE_TYPE"); + } + + // @todo this needs security checks + $resource = ORM::factory($this->resource_type, $id); + if (!$resource->loaded) { + return Kohana::show_404(); + } + + return $this->_form($resource); + } + /** * Perform a GET request on this resource * @param ORM $resource the instance of this resource type @@ -108,4 +126,10 @@ abstract class REST_Controller extends Controller { * @param ORM $resource the instance of this resource type */ abstract public function _delete($resource); + + /** + * Present a form for adding a new resource + * @param ORM $resource the resource container for instances of this resource type + */ + abstract public function _form($resource); } |