Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

merged branch lmcnearney/querystring (PR #7028)

This PR was squashed before being merged into the master branch (closes #7028).

Discussion
----------

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

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

This is related to a Silex change request: https://github.com/fabpot/Silex/pull/623

Commits
-------

4a2b755 [2.3] [Routing] Added access to querystring in RequestContext
  • Loading branch information...
commit cabec7939ec4f98c4c953aebce758f075ee66654 2 parents 0f7c5d9 + 749c69f
@fabpot fabpot authored
Showing with 34 additions and 8 deletions.
  1. +34 −8 RequestContext.php
View
42 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'));
}
/**
@@ -225,6 +229,28 @@ public function setHttpsPort($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.
*
* @return array The parameters
Please sign in to comment.
Something went wrong with that request. Please try again.