From affe4bf4a8a948cf32d816e59fa2647e90baa9e8 Mon Sep 17 00:00:00 2001 From: hack4mer Date: Tue, 9 Oct 2018 13:06:44 +0530 Subject: [PATCH] Add route defaults support --- src/Ratchet/App.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Ratchet/App.php b/src/Ratchet/App.php index da418382..e51c024a 100644 --- a/src/Ratchet/App.php +++ b/src/Ratchet/App.php @@ -97,9 +97,10 @@ public function __construct($httpHost = 'localhost', $port = 8080, $address = '1 * @param ComponentInterface $controller Your application to server for the route. If not specified, assumed to be for a WebSocket * @param array $allowedOrigins An array of hosts allowed to connect (same host by default), ['*'] for any * @param string $httpHost Override the $httpHost variable provided in the __construct + * @param array $defaulValues An array of default parameter values passed to symfony route config * @return ComponentInterface|WsServer */ - public function route($path, ComponentInterface $controller, array $allowedOrigins = array(), $httpHost = null) { + public function route($path, ComponentInterface $controller, array $allowedOrigins = array(), $httpHost = null,$defaulValues=array()) { if ($controller instanceof HttpServerInterface || $controller instanceof WsServer) { $decorated = $controller; } elseif ($controller instanceof WampServerInterface) { @@ -131,7 +132,9 @@ public function route($path, ComponentInterface $controller, array $allowedOrigi } } - $this->routes->add('rr-' . ++$this->_routeCounter, new Route($path, array('_controller' => $decorated), array('Origin' => $this->httpHost), array(), $httpHost, array(), array('GET'))); + $defaulValues['_controller'] = $decorated; + + $this->routes->add('rr-' . ++$this->_routeCounter, new Route($path, $defaulValues, array('Origin' => $this->httpHost), array(), $httpHost, array(), array('GET'))); return $decorated; }