7

I am looking for way to do this in 'right' symfony way.

VitalyP
  • 1,867
  • 6
  • 22
  • 31

1 Answers1

9

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

If you are in an action method this can be done by

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

if you are somewhere else you can get the request by getting the conext

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

For for sfWebRequest methods check the sfWebRequest API.

Note: this value could be inaccesible using proxy's

Pabloks
  • 1,484
  • 1
  • 14
  • 15