I want to upgrade from ZF2 to ZF3 right now and has the following problem with using URL parameter in my PhpRenderer.
In ZF2 I use the HelperPluginManager
to get Application
, then the MvcEvent
and finally the routeMatch
:
$routeMatch = $this
->getHelperPluginManager()
->getServiceLocator()
->get('Application')
->getMvcEvent()
->getRouteMatch();
$parameterAction = $routeMatch->getParam('action');
In ZF3 there is a deprecation warning with using the getServiceLocator()
(which makes sense, because it only returns the creationContext from the ServiceManager
). I want to find a way not trigger the warning.
Configure the Application
as a factory-using class (using \Zend\Mvc\Service\ApplicationFactory::class
) also not works, because:
Zend\View\HelperPluginManager can only create instances of Zend\View\Helper\HelperInterface and/or callables.
Is there any way to get the Application
context in my template (or better even the parameters of the URL)?