Skip to content
Browse files

fixed request dependency on the URL matcher

  • Loading branch information...
1 parent a5cb55c commit 5dc7c27f10b6f9aff307e3a150253d7f259bfa4f @fabpot committed Mar 29, 2013
Showing with 34 additions and 6 deletions.
  1. +1 −6 src/Silex/Application.php
  2. +33 −0 src/Silex/RequestContext.php
View
7 src/Silex/Application.php
@@ -28,7 +28,7 @@
use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\RouteCollection;
-use Symfony\Component\Routing\RequestContext;
+use Silex\RequestContext;
use Silex\RedirectableUrlMatcher;
use Silex\ControllerResolver;
use Silex\EventListener\LocaleListener;
@@ -125,11 +125,6 @@ public function __construct(array $values = array())
});
$this['url_matcher'] = $this->share(function () use ($app) {
- // Inject the query string into the RequestContext for Symfony versions <= 2.2
- if ($app['request']->server->get('QUERY_STRING') !== '' && !method_exists($app['request_context'], 'getQueryString')) {
- $app['request_context']->setParameter('QUERY_STRING', $app['request']->server->get('QUERY_STRING'));
- }
-
return new RedirectableUrlMatcher($app['routes'], $app['request_context']);
});
View
33 src/Silex/RequestContext.php
@@ -0,0 +1,33 @@
+<?php
+
+/*
+ * This file is part of the Silex framework.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Silex;
+
+use Symfony\Component\Routing\RequestContext as BaseRequestContext;
+use Symfony\Component\HttpFoundation\Request;
+
+/**
+ * Request Context for Symfony <= 2.2
+ *
+ * @author Fabien Potencier <fabien@symfony.com>
+ */
+class RequestContext extends BaseRequestContext
+{
+ public function fromRequest(Request $request)
+ {
+ parent::fromRequest($request);
+
+ // Inject the query string as a parameter for Symfony versions <= 2.2
+ if (!method_exists($this, 'getQueryString') && '' !== $qs = $request->server->get('QUERY_STRING')) {
+ $this->setParameter('QUERY_STRING', $qs);
+ }
+ }
+}

0 comments on commit 5dc7c27

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