In my controller, I have a postDispatch to consolidate my FlashMessenger messages:
public function postDispatch()
{       
    $messages = $this->_helper->getHelper ( 'FlashMessenger' )
        ->getMessages ();
    if ( $this->_helper->getHelper ( 'FlashMessenger' )
        ->hasCurrentMessages () )
    {
        $messages = array_merge ( $messages, $this->_helper->getHelper ( 'FlashMessenger' )
            ->getCurrentMessages () );
        $this->_helper->getHelper ( 'FlashMessenger' )
            ->clearCurrentMessages ();
    }
    $this->view->alert = $messages;
}
I want to make this into a Controller plugin.
UPDATE: I realized why I need this - I want to pass my flash messages in JSON when called by the JSON context. Unless the messages are added to the View object, I don't receive the messages.
I was able to get the messages into an array, but I don't know how to pass them to the view:
class Plugin_FlashMessenger extends Zend_Controller_Plugin_Abstract
{
    public function postDispatch($request)
    {
        $flashmessenger = Zend_Controller_Action_HelperBroker::getStaticHelper ( 'FlashMessenger' );
        $messages = $flashmessenger->getMessages ();
        if ( $flashmessenger->hasCurrentMessages () )
        {
            $messages = array_merge ( $messages, $flashmessenger->getCurrentMessages () );
            $flashmessenger->clearCurrentMessages ();
        }
        // THIS LINE IS WRONG. HOW DO I SEND $messages TO THE VIEW?
        $this->view->alert = $messages;
    }
}
Bonus question - is this the right way to accomplish this? Thanks!
 
                        
If you are just looking to get this functionality in all of your controllers, you can just extend the Zend_Controller_Action and make a new class containing your post dispatch code.