Skip to content

Commit

Permalink
[2.3] [Routing] Added access to querystring in RequestContext
Browse files Browse the repository at this point in the history
  • Loading branch information
lmcnearney authored and fabpot committed Mar 23, 2013
1 parent ea25267 commit 4a2b755
Showing 1 changed file with 34 additions and 8 deletions.
42 changes: 34 additions & 8 deletions src/Symfony/Component/Routing/RequestContext.php
Expand Up @@ -29,6 +29,7 @@ class RequestContext
private $scheme;
private $httpPort;
private $httpsPort;
private $queryString;

/**
* @var array
Expand All @@ -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);
Expand All @@ -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)
Expand All @@ -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'));
}

/**
Expand Down Expand Up @@ -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.
*
Expand Down

0 comments on commit 4a2b755

Please sign in to comment.