From 9f3770eedb8491e8810026382366c065685bedbb Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Tue, 18 Dec 2018 10:33:01 +0100 Subject: [PATCH] API: Populate default routes only when they are resolved Refs #1708. --- framework/core/src/Api/ApiServiceProvider.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/framework/core/src/Api/ApiServiceProvider.php b/framework/core/src/Api/ApiServiceProvider.php index d49398eae..d904ec3d9 100644 --- a/framework/core/src/Api/ApiServiceProvider.php +++ b/framework/core/src/Api/ApiServiceProvider.php @@ -43,6 +43,10 @@ class ApiServiceProvider extends AbstractServiceProvider return new RouteCollection; }); + $this->app->afterResolving('flarum.api.routes', function (RouteCollection $routes) { + $this->populateRoutes($routes); + }); + $this->app->singleton('flarum.api.middleware', function (Application $app) { $pipe = new MiddlewarePipe; @@ -90,8 +94,6 @@ class ApiServiceProvider extends AbstractServiceProvider */ public function boot() { - $this->populateRoutes($this->app->make('flarum.api.routes')); - $this->registerNotificationSerializers(); AbstractSerializeController::setContainer($this->app);