[Router] Update the Url QueryString of the request object with the parameters return by the UrlMatcher to let the developer access thoses parameters
This commit is contained in:
parent
f2c67b3460
commit
74fb2a691b
@ -3,6 +3,7 @@ namespace Ratchet\Http;
|
|||||||
use Ratchet\ConnectionInterface;
|
use Ratchet\ConnectionInterface;
|
||||||
use Guzzle\Http\Message\RequestInterface;
|
use Guzzle\Http\Message\RequestInterface;
|
||||||
use Guzzle\Http\Message\Response;
|
use Guzzle\Http\Message\Response;
|
||||||
|
use Guzzle\Http\Url;
|
||||||
use Symfony\Component\Routing\Matcher\UrlMatcherInterface;
|
use Symfony\Component\Routing\Matcher\UrlMatcherInterface;
|
||||||
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
|
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
|
||||||
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
||||||
@ -46,6 +47,16 @@ class Router implements HttpServerInterface {
|
|||||||
throw new \UnexpectedValueException('All routes must implement Ratchet\Http\HttpServerInterface');
|
throw new \UnexpectedValueException('All routes must implement Ratchet\Http\HttpServerInterface');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$parameters = array();
|
||||||
|
foreach($route as $key => $value) {
|
||||||
|
if (!in_array($key, array('_controller', '_route'))) {
|
||||||
|
$parameters[$key] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$url = Url::factory($request->getPath());
|
||||||
|
$url->setQuery($parameters);
|
||||||
|
$request->setUrl($url);
|
||||||
|
|
||||||
$conn->controller = $route['_controller'];
|
$conn->controller = $route['_controller'];
|
||||||
$conn->controller->onOpen($conn, $request);
|
$conn->controller->onOpen($conn, $request);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user