开发者

Can't load Action Helpers in Zend-framework application

I'm trying to create an Action Helper, but I'm havin't a hard time loading it and I'm getting this error:

Message: Action Helper by name Usersession not found

In my controllers action method,开发者_开发百科 where i'm trying to call this helper, I have this:

Zend_Controller_Action_HelperBroker::addPath('/helpers/');
Zend_Controller_Action_HelperBroker::addPrefix('Helper');
$userSession = $this->_helper->getHelper('Usersession');
$this->view->session = $userSession->eendersWat();

I'd actually prefere to load my helpers from bootstrap.php, but wasn't able to figure that out neither.

My helpers are located in application/controller/helpers. My helper filename is Usersession.php and the class is called Helper_Usersession

Any ideas why this isn't working?


I use something like the following in Bootstrap:

protected function _initHelperPath()
{
    Zend_Controller_Action_HelperBroker::addPath(
            APPLICATION_PATH . '/controllers/helpers',
            'Application_Controller_Action_Helper_');
}

The helper class is then named 'Application_Controller_Action_Helper_Usersession' and the file is located in application/controllers/helpers/Usersession.php

Of course, this presumes you are using Application_ as your application namespace. In your case, it appears that you are using an empty application namespace and none of my wordy Controller_Action_ infix, so your's would be something like:

protected function _initHelperPath()
{
    Zend_Controller_Action_HelperBroker::addPath(
            APPLICATION_PATH . '/controllers/helpers',
            'Helper_');
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜