【发布时间】:2014-12-22 17:14:15
【问题描述】:
我设法弄清楚了 zf2 中路由的基础知识。我现在遇到了一个绊脚石,因为我需要在我的客户控制器中路由到不同的方法。这是我基于社区答案的尝试:
// Customers Routing
'customers' => array(
'type' => 'Segment',
'options' => array(
'route' => '/api/customers[/]',
'defaults' => array(
'__NAMESPACE__' => 'Application\Controller',
'controller' => 'Customers',
'action' => 'index'
),
),
'may_terminate' => true,
'child_routes' => array (
'add-product' => array(
'type' => 'method',
'options' => array(
'verb' => 'get',
),
'child_routes' => array(
// actual route is a child of the method
'form' => array(
'may_terminate' => true,
'type' => 'Segment',
'options' => array(
'route' => '/api/customers/[:id][/]',
'defaults' => array(
'controller' => 'Customers',
'action' => 'all',
),
),
),
),
),
),
),
【问题讨论】: