The task of the request class is to route requests to the appropriate controller action and to provide information about the current request.
You can request a controller action within another controller action using subrequests.
$response = Request::factory('controller/action')->execute();
The controller method returns the name of the requested controller.
$controllerName = $this->request->controller();
The action method returns the name of the requested controller.
$actionName = $this->request->action();
The ip method returns the ip address of the client who made the request.
$ip = $this->request->ip();
The referer method returns the URL of the referer.
$referer = $this->request->referer();
The route method returns the route of the main request.
$route = $this->request->route();
The method method returns the request method that was used to access the page.
if($this->request->method() == 'POST')
{
// Do something
}
The isAjax method returns TRUE if the page was requested using AJAX and FALSE it not.
if($this->request->isAjax())
{
// Do something
}
The isSecure method returns TRUE if the page was requested using HTTPS and FALSE it not.
if($this->request->isSecure())
{
// Do something
}
The isMain method returns TRUE this is is the main request and FALSE if its a subrequest.
if($this->request->isMain())
{
// Do something
}