how to get controller and action name in Kohana
i just got a quick fix in kohana which is giving a problem,
i have a base class and alot of the classes which extend base class.
all of the classes have after() met开发者_开发问答hod, which call the after() method of base class.
now in base class's after() method, i want to record the controller and action name (will add this in D.B)
but how can i get controller and action name in base class.
one way is to modify after() method of each class to pass parameter to parent after() method
or i can get this info from url.
but i am looking for even more automated way, if there is any
The current controller and action can always be called with these lines, also in your base classes:
$controller = $this->request->controller();
$action = $this->request->action();
Or, if you are in a subrequest:
$controller = Request::initial()->controller();
$action = Request::initial()->action();
精彩评论