在 Zend View helper(extends Zend_View_Helper_Abstract
)中是否有可能获取有关调用该 helper 的模块/ Controller /操作的信息?
最佳答案
是的。您可以在 View 助手中使用 Zend_Controller_Front::getInstance()
。所以你可以这样做:
class App_Helper_DoSomething extends Zend_View_Helper_Abstract
{
public function doSomething()
{
return Zend_Controller_Front::getInstance()
->getRequest()
->getControllerName();
}
}
在您的 View 中调用时将打印当前 Controller 名称:
echo $this->doSomething();
关于php - 在 View 助手中获取请求信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2021092/