diff --git a/src/opnsense/mvc/app/config/services.php b/src/opnsense/mvc/app/config/services.php index 53460243835..be571dc6358 100644 --- a/src/opnsense/mvc/app/config/services.php +++ b/src/opnsense/mvc/app/config/services.php @@ -101,8 +101,10 @@ /** * Setup router */ -$di->set('router', function () use ($config) { +$di->set('router', function () use ($config, $di) { $routing = new Routing($config->application->controllersDir, "ui"); - $routing->getRouter()->handle($_SERVER['REQUEST_URI']); - return $routing->getRouter(); + $router = $routing->getRouter(); + $router->setDI($di); + $router->handle($_SERVER['REQUEST_URI']); + return $router; }); diff --git a/src/opnsense/mvc/app/config/services_api.php b/src/opnsense/mvc/app/config/services_api.php index f1106d0ff0c..e00577ad1bc 100644 --- a/src/opnsense/mvc/app/config/services_api.php +++ b/src/opnsense/mvc/app/config/services_api.php @@ -87,10 +87,12 @@ /** * Setup router */ -$di->set('router', function () use ($config) { +$di->set('router', function () use ($config, $di) { $routing = new Routing($config->application->controllersDir, "api"); - $routing->getRouter()->handle($_SERVER['REQUEST_URI']); - return $routing->getRouter(); + $router = $routing->getRouter(); + $router->setDI($di); + $router->handle($_SERVER['REQUEST_URI']); + return $router; }); // exception handling