Determine default route after extensions

Fixes #1819.
This commit is contained in:
Franz Liedke 2019-07-30 00:56:29 +02:00 committed by Daniël Klabbers
parent 970c0f5604
commit 9758dfac47

View File

@ -51,6 +51,10 @@ class ForumServiceProvider extends AbstractServiceProvider
return $routes;
});
$this->app->afterResolving('flarum.forum.routes', function (RouteCollection $routes) {
$this->setDefaultRoute($routes);
});
$this->app->singleton('flarum.forum.middleware', function (Application $app) {
$pipe = new MiddlewarePipe;
@ -179,7 +183,16 @@ class ForumServiceProvider extends AbstractServiceProvider
$this->app->make('events')->fire(
new ConfigureForumRoutes($routes, $factory)
);
}
/**
* Determine the default route.
*
* @param RouteCollection $routes
*/
protected function setDefaultRoute(RouteCollection $routes)
{
$factory = $this->app->make(RouteHandlerFactory::class);
$defaultRoute = $this->app->make('flarum.settings')->get('default_route');
if (isset($routes->getRouteData()[0]['GET'][$defaultRoute])) {