diff --git a/src/Bear/Routing/SymfonyRoutingAdapter.php b/src/Bear/Routing/SymfonyRoutingAdapter.php index 7b275cd..58139e3 100644 --- a/src/Bear/Routing/SymfonyRoutingAdapter.php +++ b/src/Bear/Routing/SymfonyRoutingAdapter.php @@ -75,9 +75,6 @@ public function resolve(string $uri, string $method): RoutingResolution */ public function init(): void { - $context = new RequestContext(); - $context->fromRequest($this->request); - $this->router = new Router($this->loader, $this->resource, [], $context); } /** @@ -85,6 +82,13 @@ public function init(): void */ public function getRouter(): Router { + if (!$this->router) { + $context = new RequestContext(); + $context->fromRequest($this->request); + + $this->router = new Router($this->loader, $this->resource, [], $context); + } + return $this->router; } }