You probably want to implement `ServiceLocatorAwareInterface` instead. Anyway, Di works also with 2.1.4 :)
Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ On 14 March 2013 18:14, RobinvdM [via Zend Framework Community] < [email protected]> wrote: > We been using ZF 2.0 for a couple of months now. We've build an extensive > library for our personal purposes, which contains extensions to the ZF > library, view helpers, custom validators etc. > > In our view helpers using ZF 2.0, it used to be possible to use the DI in > a view helper. For example, we've used the ServiceManager to locate the > translate service in a view helper: > > <code> > <?php > namespace Shared\View\Helper; > > class RenderForm extends AbstractHelper implements > ServiceManagerAwareInterface { > public function renderElement($element, $options = []) { > $messages = > $this->getServiceManager()->getServiceLocator()->get('translator')->translateElementMessages($this->form, > $element); > > (...) > } > > public function setServiceManager(ServiceManager $serviceManager) { > $this->serviceManager = $serviceManager; > } > public function getServiceManager() { > return $this->serviceManager; > } > } > </code> > > Lately, we've tried to use ZF 2.1.4 with our code base. After some minor > changes, we've stalled on the problem of using the DI in the view helpers. > Is my understanding correct that it is no longer possible to use the DI in > the view helpers? If so, are there alternatives? > > I've failed to find information about this issue using Google and the > search functionality of this board. > > ------------------------------ > If you reply to this email, your message will be added to the discussion > below: > > http://zend-framework-community.634137.n4.nabble.com/Using-DI-in-view-helper-in-ZF-2-1-tp4659474.html > To start a new topic under Zend Framework, email > [email protected] > To unsubscribe from Zend Framework Community, click > here<http://zend-framework-community.634137.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=634137&code=b2NyYW1pdXNAZ21haWwuY29tfDYzNDEzN3wxNzE0OTI1MTk4> > . > NAML<http://zend-framework-community.634137.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> > -- View this message in context: http://zend-framework-community.634137.n4.nabble.com/Using-DI-in-view-helper-in-ZF-2-1-tp4659474p4659547.html Sent from the Zend Framework mailing list archive at Nabble.com.
