Renaming parameters in Route::ONE_WAY
Notice: This thread is very old.
- fidLi
- Member | 41
Hello,
I have old url route, that generates such urls:
... template/banner?h=..&e=...
I would like to translate (forward/redirect this to to other presenter)
Something like
$router[] = new Route('template/banner', array(
'presenter' => 'Export',
'action' => 'default',
'hash' => '@h',
'email' => '@e'
), Route::ONE_WAY);
In a way that this ends up working same as the following route, where parameter hash is original parameter h and parameter email is original parameter e.
$router[] = new Route('export/<hash>', array(
'presenter' => 'Export',
'action' => 'default',
));
So basically the original url is just alias to this url:
export/...?email=...
Is there any way that I could remap the parameters using only routes?
Thanks
- fidLi
- Member | 41
It works, thank you:)
Solved this way:
$router[] = new Route('template/banner', array(
'presenter' => 'Export',
'action' => 'default',
null => array(
Route::FILTER_IN => function(array $params) {
$outParams = array();
if(isset($params["e"])){
$outParams["email"] = $params["e"];
}
if(isset($params["h"])){
$outParams["hash"] = $params["h"];
}
$outParams["presenter"] = $params["presenter"];
$outParams["action"] = $params["action"];
return $outParams;
},
Route::FILTER_OUT => function(array $params) {
return $params;
}
),
), Route::ONE_WAY);