[英]Can I get the action in the before() method of a controller in Kohana 3?
我的控制器有......
class Controller_Staff extends Controller {
public function before() {
parent::before();
$id = $this->request->param('id');
$action = $this->request->param('action');
}
public function action_get($id) {
var_dump($id);
}
}
我的路線是......
Route::set('a', 'bla/<action>/<id>',
array('id' => '\d+', 'action' => '(get|set)'))
->defaults(array(
'controller' => 'staff',
'action' => 'set'
));
當我輸入一個調用Controller_Staff->before()
(在調用action_get()
Controller_Staff->before()
的URL( bla/get/42
)時,可以在before()
訪問$id
,但是$action
始終為NULL
。
有沒有更好的方法來訪問before()
方法中的當前$action
?
謝謝。
找到了!
結果很容易。
$action = $this->request->action;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.