Redirect Controller Plugin Redirect to Referer

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Redirect Controller Plugin Redirect to Referer

richard
This post has NOT been accepted by the mailing list yet.
Hi,

Post redirect get behaviour may be required to reflect the point of initiation ie referer.

This can be achieved easily like so:
$request = new \Zend\Http\Request;
$referer = $this->getEvent()->getRouter()->match( $request->setUri($this->getRequest()->getHeader('referer')->getUri()) );
if( $referer ) {
    return $this->redirect()->toRoute( $referer->getMatchedRouteName(), $referer->getParams() );
}

so if the request came from a matched route, redirect back to it.

I would like to see similar functionality in the redirect controller plugin, eg. $this->redirect()->toReferer();
or is this functionality already implemented ?

Regards