« Yaf_Route_Supervar
Yaf_Route_Supervar::__construct »

Yaf_Route_Supervar::assemble

(Yaf >=2.3.0)

Yaf_Route_Supervar::assemble — URL を組み立てる

説明

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

URL を組み立てます

パラメータ

info

query

戻り値

文字列を返します。

エラー / 例外

info に キー ':c' と ':a' が設定されていなかった場合、 Yaf_Exception_TypeError をスローします。

例

例1 Yaf_Route_Supervar::assemble() の例

<?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'"
関連キーワード:
Route   Supervar   tkey   tval   assemble   router   info   supervar   dump   yafaction   yafmodule   query   Exception   route   getRoute   yafcontroller   construct   キー   TypeError   Router   addRoute   catch   getMessage   need   specify
関連する関数・ページ:
yaf-route-simple.assemble   yaf-route-map.assemble   yaf-route-static.assemble   class.yaf-route-supervar   yaf-route-regex.assemble   yaf-route-rewrite.assemble