我已经想出了如何让一个简单的资源可以被AbstractRestfulController访问。示例:
localhost/products ->列表
localhost/products/1 ->特殊产品
有没有办法嵌套资源?如果是这样的话,你会怎么做?示例:
localhost/products/1/photos ->列出产品的所有照片
localhost/products/1/photos/3124 ->展示产品的特殊照片
(我在这个presentation中有目标思维)
谢谢你的帮忙!
发布于 2012-12-05 04:50:34
您需要添加另一条路由。例如:
'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'
)
),
)
)发布于 2015-07-22 21:59:40
'products' => array(
'type' => 'Segment',
'options' => array(
'route' => '/products/:productId[/photos/:photos]',
'constraints' => array(
'productId' => '[0-9]*',
'photos' => '[0-9]*'
),
'defaults' => array(
'controller' => 'your contrller',
),
),
),https://stackoverflow.com/questions/13642896
复制相似问题