As long as your controllers implement the ServiceLocatorAwareInterface (and 
they probably do already), you can do it like this:

$helper = 
$this->getServiceLocator()->get('viewmanager')->getRenderer()->plugin('helper-name');

Perhaps there is a more direct route, but this is how I've been doing it.

Also, it probably goes without saying, but I think using view helpers in a 
controller is not generally recommended.  However, I also understand that 
sometimes you can't easily avoid it (though it may be a sign that something 
ought to be refactored).

- Demian
________________________________________
From: Ralf Eggert [[email protected]]
Sent: Friday, August 24, 2012 5:03 AM
To: [email protected]
Subject: Re: [fw-general] ZF2: Access FlashMessenger from view helper

Hi again,

additional question. Is it possible to access a view helper from an
action controller?

Best regards,

Ralf

--
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]



--
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to