【发布时间】:2011-01-02 21:51:49
【问题描述】:
尝试使用 preDispatch 方法使控制器助手在某些控制器中具有类似的功能。
错误:
Fatal error: Class 'Helper_Action_Test' not found in /var/www/zend.dev/application/Bootstrap.php on line 9`
应用布局
/Application
/Helpers
**/Actions** this is where i will save the classes
/Views
/modules
/configs
/layouts
/Bootstrap.php
在我添加的 Bootstrap 中:
protected function _initActionHelpers(){
Zend_Controller_Action_HelperBroker::addHelper(new Helper_Action_Test());
}
在我的帮助文件中:
class Helper_Action_Test extends Zend_Controller_Action_Helper_Abstract{
public function preDispatch() {
echo 'Test';
}
}
当我在引导程序中执行此操作时,它可以工作,它可能与包含或我尝试使用 addHelper() 实例化新类的方式有关;
include(APPLICATION_PATH.'/helpers/action/Test.php');
Zend_Controller_Action_HelperBroker::addHelper(new Test());
有什么想法吗?
【问题讨论】:
标签: zend-framework