Kohana:为什么这条路线不能完全生成?

时间:2022-11-02 21:07:37

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:

然后我有以下uri请求生成路由:

echo Route::get('cycleadmin')->uri(array('action' => 'add'));

But this ends up only returning: /cycleadmin

但这最终只返回:/ cycleadmin

I'm using Kohana 3.1 (v3.1.1.1). This worked perfectly in Kohana 3.0.9.

我正在使用Kohana 3.1(v3.1.1.1)。这在Kohana 3.0.9中完美运行。

What am I missing?

我错过了什么?

2 个解决方案

#1


1  

Try to also set <model> . Does it work?

尝试也设置 。它有用吗?

Regards

问候

Sorin

索林

#2


1  

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).

从3.1开始,route :: get() - 方法没有填写默认值 - 您必须手动指定每个参数。不要问我为什么,但这是有意的行为(来源:官方论坛)。

#1


1  

Try to also set <model> . Does it work?

尝试也设置 。它有用吗?

Regards

问候

Sorin

索林

#2


1  

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).

从3.1开始,route :: get() - 方法没有填写默认值 - 您必须手动指定每个参数。不要问我为什么,但这是有意的行为(来源:官方论坛)。