I have a symfony2 controller in which I want to do the following:
try {
return $this->redirect($request->headers->get('referer'));
}
catch (Exception $e) {
return $this->redirectToRoute('home');
}
This does not work. The idea is that given what happens in this controller, user permissions can change. So I want to know if it can still access the current route, if so, redirect to the current route, if not, redirect to the main one.
How can i do this?
Thank you so much!
source
share