Reputation: 33378
I'm getting the following error:
Strict (2048): Non-static method Controller::referer() should not be called statically,
assuming $this from incompatible context [APP/View/Questions/admin_edit.ctp, line 20]
Caused by this:
//in app/View/Questions/admin_edit.ctp
echo $this->Html->link('Cancel', Controller::referer() );
Why?
Upvotes: 5
Views: 11276
Reputation: 405
$referer_url = $this->referer('/', true); // you will get like (without base URL) "/users/profile"
$refererController = Router::parse($referer_url); // this will return $referer_url as array which contains
Array (
[controller] => users
[action] => profile
}
if anyone face any error when you use Router::parse($referer_url)
please add cakephp routing in your controller
use Cake\Routing\Router;
Upvotes: 0
Reputation: 21743
You don't. You use the request object instead:
$this->request->referer();
The controller does nothing else internally.
Careful: the referer can be empty and thus you might want to provide a fallback here in that case.
Also note the optional param $local:
@param boolean $local If true, restrict referring URLs to local server
Upvotes: 15