Added the possiblity to define custom routes from plugins
This commit is contained in:
@@ -41,6 +41,16 @@ class Request extends Base
|
||||
$this->cookies = empty($cookies) ? $_COOKIE : $cookies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set GET parameters
|
||||
*
|
||||
* @param array $params
|
||||
*/
|
||||
public function setParams(array $params)
|
||||
{
|
||||
$this->get = array_merge($this->get, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get query string string parameter
|
||||
*
|
||||
@@ -146,6 +156,17 @@ class Request extends Base
|
||||
return isset($this->files[$name]['tmp_name']) ? $this->files[$name]['tmp_name'] : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return HTTP method
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function getMethod()
|
||||
{
|
||||
return $this->getServerVariable('REQUEST_METHOD');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the HTTP request is sent with the POST method
|
||||
*
|
||||
@@ -154,7 +175,7 @@ class Request extends Base
|
||||
*/
|
||||
public function isPost()
|
||||
{
|
||||
return isset($this->server['REQUEST_METHOD']) && $this->server['REQUEST_METHOD'] === 'POST';
|
||||
return $this->getServerVariable('REQUEST_METHOD') === 'POST';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -203,7 +224,7 @@ class Request extends Base
|
||||
public function getHeader($name)
|
||||
{
|
||||
$name = 'HTTP_'.str_replace('-', '_', strtoupper($name));
|
||||
return isset($this->server[$name]) ? $this->server[$name] : '';
|
||||
return $this->getServerVariable($name);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,18 +235,18 @@ class Request extends Base
|
||||
*/
|
||||
public function getRemoteUser()
|
||||
{
|
||||
return isset($this->server[REVERSE_PROXY_USER_HEADER]) ? $this->server[REVERSE_PROXY_USER_HEADER] : '';
|
||||
return $this->getServerVariable(REVERSE_PROXY_USER_HEADER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns current request's query string, useful for redirecting
|
||||
* Returns query string
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function getQueryString()
|
||||
{
|
||||
return isset($this->server['QUERY_STRING']) ? $this->server['QUERY_STRING'] : '';
|
||||
return $this->getServerVariable('QUERY_STRING');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -236,7 +257,7 @@ class Request extends Base
|
||||
*/
|
||||
public function getUri()
|
||||
{
|
||||
return isset($this->server['REQUEST_URI']) ? $this->server['REQUEST_URI'] : '';
|
||||
return $this->getServerVariable('REQUEST_URI');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -269,7 +290,7 @@ class Request extends Base
|
||||
);
|
||||
|
||||
foreach ($keys as $key) {
|
||||
if (! empty($this->server[$key])) {
|
||||
if ($this->getServerVariable($key) !== '') {
|
||||
foreach (explode(',', $this->server[$key]) as $ipAddress) {
|
||||
return trim($ipAddress);
|
||||
}
|
||||
@@ -287,6 +308,18 @@ class Request extends Base
|
||||
*/
|
||||
public function getStartTime()
|
||||
{
|
||||
return isset($this->server['REQUEST_TIME_FLOAT']) ? $this->server['REQUEST_TIME_FLOAT'] : 0;
|
||||
return $this->getServerVariable('REQUEST_TIME_FLOAT') ?: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get server variable
|
||||
*
|
||||
* @access public
|
||||
* @param string $variable
|
||||
* @return string
|
||||
*/
|
||||
public function getServerVariable($variable)
|
||||
{
|
||||
return isset($this->server[$variable]) ? $this->server[$variable] : '';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user