API: Populate default routes only when they are resolved

Refs #1708.
This commit is contained in:
Franz Liedke 2018-12-18 10:33:01 +01:00
parent e27cd69974
commit 9f3770eedb

View File

@ -43,6 +43,10 @@ class ApiServiceProvider extends AbstractServiceProvider
return new RouteCollection; return new RouteCollection;
}); });
$this->app->afterResolving('flarum.api.routes', function (RouteCollection $routes) {
$this->populateRoutes($routes);
});
$this->app->singleton('flarum.api.middleware', function (Application $app) { $this->app->singleton('flarum.api.middleware', function (Application $app) {
$pipe = new MiddlewarePipe; $pipe = new MiddlewarePipe;
@ -90,8 +94,6 @@ class ApiServiceProvider extends AbstractServiceProvider
*/ */
public function boot() public function boot()
{ {
$this->populateRoutes($this->app->make('flarum.api.routes'));
$this->registerNotificationSerializers(); $this->registerNotificationSerializers();
AbstractSerializeController::setContainer($this->app); AbstractSerializeController::setContainer($this->app);