获取当前控制器 [英] get current controller
本文介绍了获取当前控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我想访问当前控制器的函数中:
in a function I want to reach current controller:
$front = Zend_Controller_Front::getInstance();
这只给出了一个处理程序,而不是当前的控制器.
this only gives a handler but not current controller.
我将代码从函数更改为控制器内部.并询问了我从 getInstance 和 this 获得的处理程序的来源
I changed the code from function to inside of controller. and asked their origins both the handler I got from getInstance and this
var_dump(get_class($front), get_class($this));
我明白了:
string 'Zend_Controller_Front' (length=21)
string 'IndexController' (length=15)
我怎样才能到达真正启动的前端控制器?
How can I reach real initiated front controller?
我不能作为参数传递,因为这个函数被使用了万亿次.
I cant pass as a parameter, because this function is used trillion times.
推荐答案
Zend_Controller_Front::getInstance()->getRequest()->getControllerName();
这篇关于获取当前控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文