CakePHP自定义路由w/%20在url中想要替换w/“-";不知道如何在路线上实现这一点


CakePHP custom route w/ %20 in url want to replace w/ "-" not sure how to make this happen in the route

我的链接:

echo $link->link($planDetailsByCompany['PlanDetail']['name'],
    array('controller' => 'plan_details', 'action' => 'view_benefit_schedule',
    'id' => $planDetailsByCompany['PlanDetail']['id'],
    'slug' =>  $planDetailsByCompany['PlanDetail']['name']));

我的自定义路线:

Router::connect('/pd/:id-:slug',
    array('controller' => 'plan_details', 'action' => 'view_benefit_schedule'),
    array('pass' => array('id', 'slug'),
    'id' => '[0-9]+'));

我的url显示如下:

..pd/44-Primary%20Indemnity

我无法确定如何删除%20并将其替换为"-"。公司名称中有一个空格导致了这种情况。这在CakePHP路由器功能中可能吗?如果是,如何?或者其他方法。

Geez。。我刚刚解决了这个问题!

在我上面的链接中,将"鼻涕虫"行替换为:

...'slug' =>  Inflector::slug($planDetailsByCompany['PlanDetail']['name'])...

Inflector处理url中的空格。我的结果url是:

...pd/44-Primary_Indemnity