Yaf_Route_Rewrite::assemble

(Yaf >=2.3.0)

Yaf_Route_Rewrite::assemble組合url

說明

public Yaf_Route_Rewrite::assemble(array $info, array $query = ?): string

根據(jù)指定參數(shù)和自定義參數(shù)將rewrite這個(gè)route組合成一個(gè)url

參數(shù)

info

需要傳入一個(gè)數(shù)組,數(shù)組中每個(gè)key必須和初始化rewrite route時(shí)$match參數(shù)中的帶冒號的參數(shù)名一致

query

用戶自定義的query string,將根據(jù)此路由規(guī)則拼接在url中

范例

示例 #1 Yaf_Route_Rewrite::assemble()example

router = new Yaf_Router();

$route  = new Yaf_Route_Rewrite(
                "/product/:name/:id/*",
                array(
                        'controller' => "product",
                ),
                array()
);

$router->addRoute("rewrite", $route);

var_dump($router->getRoute('rewrite')->assemble(
                        array(
                                ':name' => 'foo',
                                ':id' => 'bar',
                                ':tmpkey1' => 'tmpval1'
                        ),
                        array(
                                'tkey1' => 'tval1',
                                'tkey2' => 'tval2'
                             )
                        )
);

以上例程的輸出類似于:

string(57) "/product/foo/bar/tmpkey1/tmpval1/?tkey1=tval1&tkey2=tval2"

返回值