I have a redirection in the onBootstrap function in the Module.php file which looks like:
$url = $e->getRouter()->assemble(array(), array('name' => 'administrator/error/acl')); // redirect to this URL
$response=$e->getResponse();
$response->getHeaders()->addHeaderLine('Location', $url);
$response->setStatusCode(302);
$response->sendHeaders();
// stop further execution
$stopCallBack = function($event) use ($response){
$event->stopPropagation();
return $response;
};
$e->getApplication()->getEventManager()->attach(MvcEvent::EVENT_ROUTE, $stopCallBack,-10000);
return $response;
While the route configuration looks like this (administrator is defined and works fine with other routes):
'error'=> array(
'type' => 'Segment',
'options' => array(
'route' => '/error',
'defaults' => array(
'controller' => 'MyAdmin\Controller\Error',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'error_name' => array(
'type' => 'Segment',
'options' => array(
'route' => '/[:error_name]',
'constraints' => array(
'error_name' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
'action' => 'index',
),
),
'may_terminate' => true
),
),
),
When it tries to redirect I get the following error:
Fatal error: Uncaught exception 'Zend\Mvc\Router\Exception\RuntimeException' with message 'Route with name "acl" not found' in......
What am I doing wrong?