From c923d23f32fc63f4541f13d3eaea8148506ac624 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Wed, 19 Dec 2018 21:55:58 +0100 Subject: [PATCH] Frontends: Populate default routes only when they are resolved --- framework/core/src/Admin/AdminServiceProvider.php | 6 ++++-- framework/core/src/Forum/ForumServiceProvider.php | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/framework/core/src/Admin/AdminServiceProvider.php b/framework/core/src/Admin/AdminServiceProvider.php index ea727c2f0..2bed0a017 100644 --- a/framework/core/src/Admin/AdminServiceProvider.php +++ b/framework/core/src/Admin/AdminServiceProvider.php @@ -44,6 +44,10 @@ class AdminServiceProvider extends AbstractServiceProvider return new RouteCollection; }); + $this->app->afterResolving('flarum.admin.routes', function (RouteCollection $routes) { + $this->populateRoutes($routes); + }); + $this->app->singleton('flarum.admin.middleware', function (Application $app) { $pipe = new MiddlewarePipe; @@ -103,8 +107,6 @@ class AdminServiceProvider extends AbstractServiceProvider */ public function boot() { - $this->populateRoutes($this->app->make('flarum.admin.routes')); - $this->loadViewsFrom(__DIR__.'/../../views', 'flarum.admin'); $events = $this->app->make('events'); diff --git a/framework/core/src/Forum/ForumServiceProvider.php b/framework/core/src/Forum/ForumServiceProvider.php index 94ee49d5b..93787cf93 100644 --- a/framework/core/src/Forum/ForumServiceProvider.php +++ b/framework/core/src/Forum/ForumServiceProvider.php @@ -49,6 +49,10 @@ class ForumServiceProvider extends AbstractServiceProvider return new RouteCollection; }); + $this->app->afterResolving('flarum.forum.routes', function (RouteCollection $routes) { + $this->populateRoutes($routes); + }); + $this->app->singleton('flarum.forum.middleware', function (Application $app) { $pipe = new MiddlewarePipe; @@ -110,8 +114,6 @@ class ForumServiceProvider extends AbstractServiceProvider */ public function boot() { - $this->populateRoutes($this->app->make('flarum.forum.routes')); - $this->loadViewsFrom(__DIR__.'/../../views', 'flarum.forum'); $this->app->make('view')->share([