How to get previous page route in symfony?

I am looking for a way to do this in the correct symfony order.

+6
source share
1 answer

There is a way to get the reference page from the $ request variable. For example, if I was in myaction / mypage and click on myaction2 / mypage2 with this getReferer () method, I get ' http: // myweb / myaction / mypage .

If you are in the action method, this can be done using

public function executeMyaction(sfWebRequest $request) { $previousUrl = $request->getReferer(); ... } 

if you are somewhere else, you can get a request by receiving conext

 $previousUrl = $this->getContext()->getRequest()->getReferer(); 

For sfWebRequest methods, check the sfWebRequest API .

Note. This value may not be available using the proxy server.

+10
source share

All Articles