Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Routing 向cakephp 1.3路由添加参数_Routing_Cakephp 1.3 - Fatal编程技术网

Routing 向cakephp 1.3路由添加参数

Routing 向cakephp 1.3路由添加参数,routing,cakephp-1.3,Routing,Cakephp 1.3,我有一个MVC结构,User 它管理三类用户:用户、客户和租户;这一切都是由用户完成的 我需要的是一个隐藏参数,它将被添加到每个路由,它将告诉控制器如何完成它的工作 示例: /clients/unverified/5将被路由到/users/unverified/client/5 而/tenants/unverified/5将被路由到/users/unverified/tenant/5 如果你对如何做有更好的想法,我也将不胜感激。有几个选项向我跳出来: 1.在/app/config/routes.

我有一个MVC结构,
User

它管理三类用户:用户、客户和租户;这一切都是由
用户
完成的
我需要的是一个隐藏参数,它将被添加到每个路由,它将告诉控制器如何完成它的工作

示例:

/clients/unverified/5
将被路由到
/users/unverified/client/5

/tenants/unverified/5
将被路由到
/users/unverified/tenant/5


如果你对如何做有更好的想法,我也将不胜感激。

有几个选项向我跳出来:

1.
/app/config/routes.php
中使用
Router::connect()

此方法应导致传入ID而无需指定它(以及任何其他参数)


2.
创建
客户端
租户
控制器,
未验证的
操作并将其重定向到
用户
控制器

您可以使用相同的控制器操作,如下所示:

Router::connect('/clients/unverified/:limit',
                array('controller' => 'users', 'action' => 'unverified',
                'client','5')
);
Router::connect('/tenants/unverified/:limit',
                array('controller' => 'users', 'action' => 'unverified',
               'tenants','5')
);
Router::connect('/whatever/unverified/:limit',
                array('controller' => 'users', 'action' => 'unverified',
               'whatever','5')
);
 # $type would be clients/ tenants/ watever
 # $limit would be 5 
function unverified($type='user',$limit=5){

}
在用户控制器中

 # $type would be clients/ tenants/ watever
 # $limit would be 5 
function unverified($type='user',$limit=5){

}

请解释一下……为了清楚起见,再多解释一点……不确定我还能补充什么。其基本思想是为不同的路由获取相同的控制器>操作,并使用一个隐藏参数来指示使用哪个路由