From 99c79a499eb3195e8b9c46945ff83f18d065e1a4 Mon Sep 17 00:00:00 2001 From: Alessandro Feitoza Date: Sun, 17 Jun 2018 12:52:04 -0300 Subject: [PATCH 1/2] improvement: Adding exaples for AbstractRestfulController actions --- docs/book/controllers.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/docs/book/controllers.md b/docs/book/controllers.md index fa3d58c1b..cc2e18cbf 100644 --- a/docs/book/controllers.md +++ b/docs/book/controllers.md @@ -252,6 +252,36 @@ following matrix: should attempt to delete the given entity, and, if successful, return either a 200 or 204 response status. +Creation of action controllers looks like the following example: + +```php +namespace Foo\Controller; + +use Zend\Mvc\Controller\AbstractRestfulController; + +class BarRestController extends AbstractRestfulController +{ + //GET request with id: php.net/book/1 + public function get($id) + { + return ['title' => 'Book 1']; + } + + //GET request: php,net/book + public function get() + { + return ['title' => 'All Books']; + } + + //POST request + public function create($data) + { + return ['message' => 'Book created']; + } +} + +``` + Additionally, you can map "action" methods to the `AbstractRestfulController`, just as you would in the `AbstractActionController`; these methods will be suffixed with "Action", differentiating them from the RESTful methods listed From e6590356b1afba1479d31ab5740dd54f6d584490 Mon Sep 17 00:00:00 2001 From: Alessandro Feitoza Date: Mon, 18 Jun 2018 16:20:15 -0300 Subject: [PATCH 2/2] Update controllers.md --- docs/book/controllers.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/book/controllers.md b/docs/book/controllers.md index cc2e18cbf..c1d201737 100644 --- a/docs/book/controllers.md +++ b/docs/book/controllers.md @@ -267,8 +267,8 @@ class BarRestController extends AbstractRestfulController return ['title' => 'Book 1']; } - //GET request: php,net/book - public function get() + //GET request: php.net/book + public function getList() { return ['title' => 'All Books']; }