gpt4 book ai didi

php - 如何在 Kohana 中获取 Controller 和操作名称

转载 作者:行者123 更新时间:2023-12-03 02:16:57 25 4
gpt4 key购买 nike

我刚刚在 kohana 中快速修复了一个问题,

我有一个基类和很多扩展基类的类。

所有类都有after()方法,该方法调用基类的after()方法。

现在在基类的 after() 方法中,我想记录 Controller 和操作名称(将在 D.B 中添加此名称)

但是我如何在基类中获取 Controller 和操作名称。

一种方法是修改每个类的 after() 方法,将参数传递给父 after() 方法

或者我可以从网址获取此信息。

但我正在寻找更自动化的方法(如果有的话)

最佳答案

当前 Controller 和操作始终可以使用这些行来调用,也在您的基类中:

$controller = $this->request->controller();
$action = $this->request->action();

或者,如果您处于子请求中:

$controller = Request::initial()->controller();
$action = Request::initial()->action();

关于php - 如何在 Kohana 中获取 Controller 和操作名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7196833/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com