©
This document uses PHP Chinese website manual Release
(Yaf >=2.3.0)
Yaf_Route_Map::assemble — 组合url
$info
[, array $query
] )根据指定参数和自定义参数将map这个route组合成一个url
info
需要传入一个数组,数组的key可以为:a或者:c,:a表示action,:c表示controller。
当map route初始化时,controller_prefer为false时,这个参数需要传入:c。当controller_prefer 为true时,这个参数需要传入:a。
query
用户自定义的query string,将根据此路由规则拼接在url中
Example #1 Yaf_Route_Map::assemble() example
<?php
$router = new Yaf_Router ();
$route = new Yaf_Route_Map ();
$router -> addRoute ( "map" , $route );
var_dump ( $router -> getRoute ( 'map' )-> assemble (
array(
':c' => 'foo_bar'
),
array(
'tkey1' => 'tval1' ,
'tkey2' => 'tval2'
)
)
);
$route = new Yaf_Route_Map ( true , '_' );
$router -> addRoute ( "map" , $route );
var_dump ( $router -> getRoute ( 'map' )-> assemble (
array(
':a' => 'foo_bar'
),
array(
'tkey1' => 'tval1' ,
'tkey2' => 'tval2'
)
)
);
以上例程的输出类似于:
string(%d) "/foo/bar?tkey1=tval1&tkey2=tval2" string(%d) "/foo/bar/_/tkey1/tval1/tkey2/tval2"