How to write another default method in Controller and access via Route
Closed this issue · 3 comments
robocon commented
In Route.php I see an example
'form' => '\Controller\Form',
it will access to method run() but if I need to create another method something like product(), item() ... in the same Controller, How to access them from Route?
xeoncross commented
A single controller represents a single entity in RESTful applications. If you have other end points then you need to create additional controllers.
Controller\Post
->Get (Get a post)
->Put (update a post)
->Delete (delete a post)
->Post (create a post)
The run method is just to process the correct method like post()
robocon commented
thank you so much :)
endriu84 commented
Or in default method run() You can write:
public function run( $method )
{
$this->$method
}
public function item() {} // for example