views:

157

answers:

1

Is there any way to get access to a helper class from within a registered plugin. From within the controller, one can use:

$this->_helper->getHelper($helperName);

Specifically, we use the FlashMessenger helper to pass error and info messages around to different pages before we do a redirect. In one of our plugins, we log a user out and set the index and controller to a different page. We could manually set a value in the request but this seems to go against what the FlashMessenger is supposed to be used for and we'd have to do that just for this special case.

A: 

You should use the action helper broker to retrieve a helper anywhere outside a controller. See the similar question:

zend-framework, call an action helper from within another action helper

mercator
Thanks. I ended up trying this and was able to get the helper. In our case, though, we weren't able to use the FlashMessenger helper because it assumes there is one hop between when messages are added and the messages are able to be retrieved. In the case where you're trying to get them in a registered plugin before control gets to the controller, the controller won't have passed the required one hop when it tries to use the messages. Regardless, your answer is correct and may help others as long as they aren't trying to use the FlashMessenger.
Chris Williams