【问题标题】:Using two wildcards in CakePHP routing在 CakePHP 路由中使用两个通配符
【发布时间】:2013-10-30 00:02:22
【问题描述】:

所以我的情况有点棘手。我有一个控制器,Joints。它已经有以下路由器连接:

Router::connect('/joints/*', array('controller'=>'joints', 'action'=>'view'));

问题是现在我正在构建 API 方法来连接移动应用程序,而通配符太激进了!我需要做的是添加如下内容,这样我就可以将我的 API 方法发送到正确的操作:

Router::connect('/joints/api{$method}', array('controller'=>'joints', "action"=>"api{$method}"));

有没有办法留下我原来的通配符,当动作以“api”开头时切入内联?

【问题讨论】:

    标签: routing cakephp-2.0


    【解决方案1】:

    嗯。好像就这么简单:

    Router::connect("/joints/:action/*", array('controller'=>'joints', "action" => ":action"));
    Router::connect('/joints/*', array('controller'=>'joints', 'action'=>'view'));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-02-06
      • 2012-02-03
      • 2013-12-19
      • 1970-01-01
      • 1970-01-01
      • 2011-06-18
      • 1970-01-01
      相关资源
      最近更新 更多