src/Controller/Component/CommonComponent.php
public function autoRedirect($whereTo, $allowSelf = false, $status = 302) {
		if ($allowSelf || $this->Controller->referer(null, true) !== $this->Controller->getRequest()->getRequestTarget()) {
			return $this->Controller->redirect($this->Controller->referer($whereTo, true), $status);
		}
		return $this->Controller->redirect($whereTo, $status);
	}
public function autoRedirect($whereTo, $allowSelf = false, $status = 302) {
		if ($allowSelf || $this->Controller->referer(null, true) !== $this->Controller->getRequest()->getRequestTarget()) {
			return $this->Controller->redirect($this->Controller->referer($whereTo, true), $status);
		}
		return $this->Controller->redirect($whereTo, $status);
	}
public function autoRedirect ( $ whereTo , $ allowSelf = false , $ status = 302 ) { if ( $ allowSelf || $ this -> Controller -> referer ( null , true ) !== $ this -> Controller -> getRequest ( ) -> getRequestTarget ( ) ) { return $ this -> Controller -> redirect ( $ this -> Controller -> referer ( $ whereTo , true ) , $ status ) ; } return $ this -> Controller -> redirect ( $ whereTo , $ status ) ; }
Smart Referer Redirect - will try to use an existing referer first
otherwise it will use the default url

@param mixed $whereTo URL
@param bool $allowSelf if redirect to the same controller/action (url) is allowed
@param int $status
@return \Cake\Http\Response
Smart Referer Redirect - will try to use an existing referer first otherwise it will use the default url