Kohana:为什么这条路线不能完全生成?
我的引导程序中有以下路由:
Route::set('cycleadmin', '(<lang>/)cycleadmin(/<model>(/<action>(/<id>)))', array(
'lang' => $lang_options,
'model' => '[a-z_]{0,}',
'action' => '[a-z_]+',
'id' => '\d+',
))->defaults(array(
'controller' => 'cycleadmin',
'lang' => DEFAULT_LANG,
'model' => 'cycle',
'action' => NULL,
));
然后我有以下 uri 请求来生成路由:
echo Route::get('cycleadmin')->uri(array('action' => 'add'));
但这最终只会返回: /cycleadmin
我正在使用 Kohana 3.1 (v3.1.1.1) 。这在 Kohana 3.0.9 中完美运行。
我缺少什么?
I have the following route in my bootstrap:
Route::set('cycleadmin', '(<lang>/)cycleadmin(/<model>(/<action>(/<id>)))', array(
'lang' => $lang_options,
'model' => '[a-z_]{0,}',
'action' => '[a-z_]+',
'id' => '\d+',
))->defaults(array(
'controller' => 'cycleadmin',
'lang' => DEFAULT_LANG,
'model' => 'cycle',
'action' => NULL,
));
Then I have the following uri request to generate the route:
echo Route::get('cycleadmin')->uri(array('action' => 'add'));
But this ends up only returning: /cycleadmin
I'm using Kohana 3.1 (v3.1.1.1). This worked perfectly in Kohana 3.0.9.
What am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试同时设置
。有效吗?问候
索林
Try to also set
<model>
. Does it work?Regards
Sorin
从 3.1 开始,route::get() 方法不会填充默认值 - 您必须手动指定每个参数。不要问我为什么,但这是有意的行为(来源:官方论坛)。
As of 3.1, the route::get()-method doesn't fill in the defaults - you have to manually specify every parameter. Don't ask me why, but it is intended behaviour (source: the official forums).