I took out the rest of my code, but here's the basics. This is how I call my 
function from onBootstrap and it works fine for me.

If this doesn't work for you, not sure if I could provide more assistance. :) 
Maybe because I have it attached to the "dispatch" event? Not sure what event 
you have your function attached to.

public function onBootstrap(MvcEvent $e)
{
    $eventManager        = $e->getApplication()->getEventManager();
    $moduleRouteListener = new ModuleRouteListener();

     $moduleRouteListener->attach($eventManager);

     $eventManager->attach('dispatch', array($this, 'secureSession'));
}

public function secureSession($e)
{
    $target         = $e->getTarget();
    return $target->redirect()->toUrl('/auth/login');
}



Gina-Marie Rollock
Software Developer
Network Technology Solutions
Office  119 East Jackson Street, Thomasville, GA 31792
Phone 229.584.2006   Fax 229.226.2495
Email  [email protected] 
Web  http://www.ntsnetworks.com


-----Original Message-----
From: Arvind Jha [mailto:[email protected]] 
Sent: Friday, January 16, 2015 9:13 AM
To: [email protected]
Subject: [fw-general] Re: How to use redirect() outside controller in zend 2

Thanks Gina

I tried but it says
Fatal error: Call to undefined method Zend\Mvc\Application::redirect() 

Any idea why?

Thanks




--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/How-to-use-redirect-outside-controller-in-zend-2-tp4662425p4662429.html
Sent from the Zend Framework mailing list archive at Nabble.com.

-- 
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