[2.3] [Routing] Added access to querystring in RequestContext

This commit is contained in:
Lance McNearney 2013-02-08 09:38:57 -08:00 committed by Fabien Potencier
parent ea252671b0
commit 4a2b75536e

View File

@ -29,6 +29,7 @@ class RequestContext
private $scheme;
private $httpPort;
private $httpsPort;
private $queryString;
/**
* @var array
@ -38,17 +39,18 @@ class RequestContext
/**
* Constructor.
*
* @param string $baseUrl The base URL
* @param string $method The HTTP method
* @param string $host The HTTP host name
* @param string $scheme The HTTP scheme
* @param integer $httpPort The HTTP port
* @param integer $httpsPort The HTTPS port
* @param string $path The path
* @param string $baseUrl The base URL
* @param string $method The HTTP method
* @param string $host The HTTP host name
* @param string $scheme The HTTP scheme
* @param integer $httpPort The HTTP port
* @param integer $httpsPort The HTTPS port
* @param string $path The path
* @param string $queryString The query string
*
* @api
*/
public function __construct($baseUrl = '', $method = 'GET', $host = 'localhost', $scheme = 'http', $httpPort = 80, $httpsPort = 443, $path = '/')
public function __construct($baseUrl = '', $method = 'GET', $host = 'localhost', $scheme = 'http', $httpPort = 80, $httpsPort = 443, $path = '/', $queryString = '')
{
$this->baseUrl = $baseUrl;
$this->method = strtoupper($method);
@ -57,6 +59,7 @@ class RequestContext
$this->httpPort = $httpPort;
$this->httpsPort = $httpsPort;
$this->pathInfo = $path;
$this->queryString = $queryString;
}
public function fromRequest(Request $request)
@ -68,6 +71,7 @@ class RequestContext
$this->setScheme($request->getScheme());
$this->setHttpPort($request->isSecure() ? $this->httpPort : $request->getPort());
$this->setHttpsPort($request->isSecure() ? $request->getPort() : $this->httpsPort);
$this->setQueryString($request->server->get('QUERY_STRING'));
}
/**
@ -224,6 +228,28 @@ class RequestContext
$this->httpsPort = $httpsPort;
}
/**
* Gets the query string.
*
* @return string The query string
*/
public function getQueryString()
{
return $this->queryString;
}
/**
* Sets the query string.
*
* @param string $queryString The query string
*
* @api
*/
public function setQueryString($queryString)
{
$this->queryString = $queryString;
}
/**
* Returns the parameters.
*