(Yaf >=2.3.0)
Yaf_Route_Supervar::assemble — 組合url
$info
, array $query
= ?): string根據(jù)指定參數(shù)和自定義參數(shù)將supervar這個route組合成一個url
info
需要傳入一個數(shù)組,數(shù)組中每個key可為:m、:c、:a,:m代表module,:c代表controller, :a代表action
query
用戶自定義的query string,將根據(jù)此路由規(guī)則拼接在url中
示例 #1 Yaf_Route_Supervar::assemble()example
<?php
$router = new Yaf_Router();
$route = new Yaf_Route_Supervar('r');
$router->addRoute("supervar", $route);
var_dump($router->getRoute('supervar')->assemble(
array(
':a' => 'yafaction',
'tkey' => 'tval',
':c' => 'yafcontroller',
':m' => 'yafmodule'
),
array(
'tkey1' => 'tval1',
'tkey2' => 'tval2'
)
));
try {
var_dump($router->getRoute('supervar')->assemble(
array(
':a' => 'yafaction',
'tkey' => 'tval',
':m' => 'yafmodule'
),
array(
'tkey1' => 'tval1',
'tkey2' => 'tval2',
1 => array(),
)
));
} catch (Exception $e) {
var_dump($e->getMessage());
}
以上例程的輸出類似于:
string(%d) "?r=/yafmodule/yafcontroller/yafaction&tkey1=tval1&tkey2=tval2" string(%d) "You need to specify the controller by ':c'"