开发者

zend model using helpers

Call to undefined method Application_Model_Users::_helper(开发者_如何学运维)

how can i get the redirect helper to work in models? in works in the controllers that extends the zend controller action but not in models

thanks


You can either fetch it from the within the model:

$redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');

or fetch the helper in the controller and inject it to the model, which would be somewhat cleaner:

$redirector = $this->_helper->getHelper('redirector');
$userModel = new Application_Model_Users($redirector);

But …

… like it was already pointed out in the comments - nothing in the Model should be responsible for redirecting a request, so I strongly suggest you dont do this in the Model at all. Keep this in the controller.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜