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.
精彩评论