In my project i created a Helper to display a-tags, but with an additonal check, if the user has ACL rights. When he has access to the url, i want to create the Url with the existing UrlHelper - but i can't instantiate it:
// try 1
$pluginHelper = \Zend\Mvc\Service\ViewHelperManagerFactory::createService($this->getServiceLocator());
$this->_urlHelper = $pluginHelper->get('url');
// try 2
$factory = new \Zend\Mvc\Service\RouterFactory();
$router = $this->_urlHelper = $factory->createService($this->getServiceLocator());
// try 3
$module = new \RDGOnline\Module();
$config = $module->getConfig();
$router = \Zend\Mvc\Router\Http\TreeRouteStack::factory($config['router']);
$this->_urlHelper = new Url();
$this->_urlHelper->setRouter($router);
I attempted different ways, but all failed. In my last try the url was created - but it ignores the subfolder. I.E. /trunk/
Thanks for Helping.