I use the AbstractRestfulController for a controller in my ZF2-Application. This controller implements create(), update() etc.
Is it possible to have actions next to those REST-Functions?
E.g. I want to have: url.com/model/id to get the model (this works already), but i want to be able to call url.com/model/doSomething as well.
I tried using child_routes, but it did not work:
'car' => array(
'type' => 'literal',
'options' => array(
'route' => '/car',
'defaults' => array(
'controller' => 'CarDealer\Controller\Car',
'action' => 'index'
),
),
'child_routes' => array(
'rest' => array(
'type' => 'segment',
'options' => array(
'route' => '[/:id]',
'constraints' => array(
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'CarDealer\Controller\Car',
),
),
),
'actions' => array(
'type' => 'segment',
'options' => array(
'route' => '[/:action]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'CarDealer\Controller\Car',
'action' => 'index',
),
),
),
),
),
I am pretty sure the above doesnt make so much sense, but I could not find the right hints to get things working.
Thanks for your help!