Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Fabien Potencier authored March 23, 2013

Showing 1 changed file with 34 additions and 8 deletions. Show diff stats Hide diff stats

  1. 42  RequestContext.php
42  RequestContext.php
@@ -29,6 +29,7 @@ class RequestContext
29 29
     private $scheme;
30 30
     private $httpPort;
31 31
     private $httpsPort;
  32
+    private $queryString;
32 33
 
33 34
     /**
34 35
      * @var array
@@ -38,17 +39,18 @@ class RequestContext
38 39
     /**
39 40
      * Constructor.
40 41
      *
41  
-     * @param string  $baseUrl   The base URL
42  
-     * @param string  $method    The HTTP method
43  
-     * @param string  $host      The HTTP host name
44  
-     * @param string  $scheme    The HTTP scheme
45  
-     * @param integer $httpPort  The HTTP port
46  
-     * @param integer $httpsPort The HTTPS port
47  
-     * @param string  $path      The path
  42
+     * @param string  $baseUrl      The base URL
  43
+     * @param string  $method       The HTTP method
  44
+     * @param string  $host         The HTTP host name
  45
+     * @param string  $scheme       The HTTP scheme
  46
+     * @param integer $httpPort     The HTTP port
  47
+     * @param integer $httpsPort    The HTTPS port
  48
+     * @param string  $path         The path
  49
+     * @param string  $queryString  The query string
48 50
      *
49 51
      * @api
50 52
      */
51  
-    public function __construct($baseUrl = '', $method = 'GET', $host = 'localhost', $scheme = 'http', $httpPort = 80, $httpsPort = 443, $path = '/')
  53
+    public function __construct($baseUrl = '', $method = 'GET', $host = 'localhost', $scheme = 'http', $httpPort = 80, $httpsPort = 443, $path = '/', $queryString = '')
52 54
     {
53 55
         $this->baseUrl = $baseUrl;
54 56
         $this->method = strtoupper($method);
@@ -57,6 +59,7 @@ public function __construct($baseUrl = '', $method = 'GET', $host = 'localhost',
57 59
         $this->httpPort = $httpPort;
58 60
         $this->httpsPort = $httpsPort;
59 61
         $this->pathInfo = $path;
  62
+        $this->queryString = $queryString;
60 63
     }
61 64
 
62 65
     public function fromRequest(Request $request)
@@ -68,6 +71,7 @@ public function fromRequest(Request $request)
68 71
         $this->setScheme($request->getScheme());
69 72
         $this->setHttpPort($request->isSecure() ? $this->httpPort : $request->getPort());
70 73
         $this->setHttpsPort($request->isSecure() ? $request->getPort() : $this->httpsPort);
  74
+        $this->setQueryString($request->server->get('QUERY_STRING'));
71 75
     }
72 76
 
73 77
     /**
@@ -225,6 +229,28 @@ public function setHttpsPort($httpsPort)
225 229
     }
226 230
 
227 231
     /**
  232
+     * Gets the query string.
  233
+     *
  234
+     * @return string The query string
  235
+     */
  236
+    public function getQueryString()
  237
+    {
  238
+        return $this->queryString;
  239
+    }
  240
+
  241
+    /**
  242
+     * Sets the query string.
  243
+     *
  244
+     * @param string $queryString The query string
  245
+     *
  246
+     * @api
  247
+     */
  248
+    public function setQueryString($queryString)
  249
+    {
  250
+        $this->queryString = $queryString;
  251
+    }
  252
+
  253
+    /**
228 254
      * Returns the parameters.
229 255
      *
230 256
      * @return array The parameters

0 notes on commit cabec79

Please sign in to comment.
Something went wrong with that request. Please try again.