mirror of
https://github.com/flarum/core.git
synced 2025-10-13 07:54:25 +02:00
Ensure routes are only populated after extensions have registered listeners
Because extensions can have dependencies injected, a RouteCollection could potentially be instantiated, and thus the ConfigureRoutes event would be called before extensions have had a chance to subscribe to it. Instead, we instantiate the RouteCollection on demand, but only populate it when the application boots.
This commit is contained in:
@@ -32,7 +32,7 @@ class ForumServiceProvider extends AbstractServiceProvider
|
||||
});
|
||||
|
||||
$this->app->singleton('flarum.forum.routes', function () {
|
||||
return $this->getRoutes();
|
||||
return new RouteCollection;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -41,6 +41,8 @@ class ForumServiceProvider extends AbstractServiceProvider
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->populateRoutes($this->app->make('flarum.forum.routes'));
|
||||
|
||||
$this->loadViewsFrom(__DIR__.'/../../views', 'flarum.forum');
|
||||
|
||||
$this->flushAssetsWhenThemeChanged();
|
||||
@@ -49,14 +51,12 @@ class ForumServiceProvider extends AbstractServiceProvider
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the forum client routes.
|
||||
* Populate the forum client routes.
|
||||
*
|
||||
* @return RouteCollection
|
||||
* @param RouteCollection $routes
|
||||
*/
|
||||
protected function getRoutes()
|
||||
protected function populateRoutes(RouteCollection $routes)
|
||||
{
|
||||
$routes = new RouteCollection;
|
||||
|
||||
$toController = $this->getHandlerGenerator($this->app);
|
||||
|
||||
$routes->get(
|
||||
@@ -140,8 +140,6 @@ class ForumServiceProvider extends AbstractServiceProvider
|
||||
'default',
|
||||
$toDefaultController
|
||||
);
|
||||
|
||||
return $routes;
|
||||
}
|
||||
|
||||
protected function flushAssetsWhenThemeChanged()
|
||||
|
Reference in New Issue
Block a user