Reputation: 221
I've already figured out how to make a simple resource reachable by AbstractRestfulController
. Example:
localhost/products
-> list
localhost/products/1
-> special product
Is there a way to nest resources? If so, how would you do that? Example:
localhost/products/1/photos
-> list all photos of a product
localhost/products/1/photos/3124
-> show special photo of a product
(I have in this presentation as goal mind)
Thanks for your help!
Upvotes: 0
Views: 676
Reputation: 475
'products' => array(
'type' => 'Segment',
'options' => array(
'route' => '/products/:productId[/photos/:photos]',
'constraints' => array(
'productId' => '[0-9]*',
'photos' => '[0-9]*'
),
'defaults' => array(
'controller' => 'your contrller',
),
),
),
Upvotes: 0
Reputation: 1784
You need to add another route. For instance :
'products' => array(
'type' => 'Literal',
'options' => array(
'route' => '/products',
'defaults' => array(
'controller' => 'Application\Controller\ProductsRest',
'action' => null
)
),
'may_terminate' => true,
'child_routes' => array(
'photos' => array(
'type' => 'Segment',
'options' => array(
'route' => '/:productId/photos'
)
),
)
)
Upvotes: 1