1

KO 3.2 で $this->request->uri($params) として変更されたパラメーターで uri を取得するための代替手段はありますか?

例:

//Kohana 3.1 ; current uri = articles/show/10 (<controller>/<action>/<id>)

$this->request->uri(array('id' => 11)); // return 'articles/show/11'

ありがとう

4

1 に答える 1

3

$this->request->uri()3.2 以降、現在の URI を返すようになったため、これに対する「短い」方法はありません。$this->request->route()->uri()必要なすべてのパラメーターで使用します。

$params  = array('id' => 11); // what params you want to change
$params += $this->request->param(); // current request params
$params += array(
    // note that $this->request->param() doesnt contain directory/controller/action values!
   'directory' => $this->request->directory(),
   'controller' => $this->request->controller(),
   'action' => $this->request->action(),
);
$uri = $this->request->route()->uri($params);

もちろん、このための特別なメソッド ( のようなもの$this->request->old_uri(array('id' => 11))) を作成できます。

これは、その API 変更の問題リンクです。

于 2012-05-23T06:07:27.617 に答える