我一直在拼命地与 ZF2 作战,我正在尝试创建一个路由树,以便:
- /manual - 转到手动控制器,索引操作
- /manual/[something] - 转到手动控制器,制造商操作
- /manual/[something]/[else] - 转到手动控制器,类别操作
- /manual/[something]/[else]/[foo] - 转到手动控制器,模型动作
我使用了官方文档和其他几个网站,但我所能做的就是触发:
- /manual - 转到手动控制器,索引操作
- /manual/[something] - 转到手动控制器构造函数,但不是动作...
另外两个根本没有到达控制器....
'manual' => array(
'type' => 'literal',
'options' => array(
'route' => '/manual',
'defaults' => array(
'controller' => 'Applicaton\Controller\Manual',
'action' => 'index'
),
),
'may_terminate' => true,
'child_routes' => array(
// Segment route for viewing one blog post
'manufacturer' => array(
'type' => 'segment',
'options' => array(
'route' => '/[:manufacturer]',
'constraints' => array(
'manufacturer' => '[a-zA-Z0-9_-]+'
),
'defaults' => array(
'action' => 'manufacturer'
)
),
'may_terminate' => true,
'child_routes' => array(
'category' => array(
'type' => 'segment',
'options' => array(
'route' => '/[:category]',
'constraints' => array(
'category' => '[a-zA-Z0-9_-]+'
),
'defaults' => array(
'action' => 'category'
)
),
'may_terminate' => true,
'child_routes' => array(
'model' => array(
'type' => 'segment',
'options' => array(
'route' => '/[:model]',
'constraints' => array(
'model' => '[a-zA-Z0-9_-]+'
),
'defaults' => array(
'action' => 'model'
)
)
)
)
)
)
)
)
),
提前感谢您的帮助,任何帮助将不胜感激!
更新:
这是我的控制器操作:
public function manufacturerAction() {
echo 'I am in the manufacturer action!';
return new ViewModel();
}