From 4a2b75536eed1e9803b517cac15aac8ba0c6bda1 Mon Sep 17 00:00:00 2001 From: Lance McNearney Date: Fri, 8 Feb 2013 09:38:57 -0800 Subject: [PATCH] [2.3] [Routing] Added access to querystring in RequestContext --- .../Component/Routing/RequestContext.php | 42 +++++++++++++++---- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Component/Routing/RequestContext.php b/src/Symfony/Component/Routing/RequestContext.php index 132ecc743cee..cb5369689649 100644 --- a/src/Symfony/Component/Routing/RequestContext.php +++ b/src/Symfony/Component/Routing/RequestContext.php @@ -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 @@ public function __construct($baseUrl = '', $method = 'GET', $host = 'localhost', $this->httpPort = $httpPort; $this->httpsPort = $httpsPort; $this->pathInfo = $path; + $this->queryString = $queryString; } public function fromRequest(Request $request) @@ -68,6 +71,7 @@ public function fromRequest(Request $request) $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 @@ public function setHttpsPort($httpsPort) $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. *