diff --git a/framework/core/src/Forum/Actions/IndexAction.php b/framework/core/src/Forum/Actions/IndexAction.php index 2671b7d2b..537f0f727 100644 --- a/framework/core/src/Forum/Actions/IndexAction.php +++ b/framework/core/src/Forum/Actions/IndexAction.php @@ -7,6 +7,7 @@ use Cookie; use Config; use View; use DB; +use Flarum\Forum\Events\RenderView; class IndexAction extends BaseAction { @@ -32,14 +33,25 @@ class IndexAction extends BaseAction } } - return View::make('flarum.forum::index') + $view = View::make('flarum.forum::index') ->with('title', Config::get('flarum::forum_title', 'Flarum Demo Forum')) - ->with('styles', app('flarum.forum.assetManager')->getCSSFiles()) - ->with('scripts', app('flarum.forum.assetManager')->getJSFiles()) ->with('config', $config) - ->with('layout', View::make('flarum.forum::forum')) + ->with('layout', 'flarum.forum::forum') ->with('data', $data) ->with('session', $session) ->with('alert', $alert); + + $assetManager = app('flarum.forum.assetManager'); + $root = __DIR__.'/../../..'; + $assetManager->addFile([ + $root.'/js/forum/dist/app.js', + $root.'/less/forum/app.less' + ]); + + event(new RenderView($view, $assetManager)); + + return $view + ->with('styles', $assetManager->getCSSFiles()) + ->with('scripts', $assetManager->getJSFiles()); } } diff --git a/framework/core/src/Forum/Events/BootForum.php b/framework/core/src/Forum/Events/BootForum.php deleted file mode 100644 index 46162ca67..000000000 --- a/framework/core/src/Forum/Events/BootForum.php +++ /dev/null @@ -1,11 +0,0 @@ -app = $app; - } -} diff --git a/framework/core/src/Forum/Events/RenderView.php b/framework/core/src/Forum/Events/RenderView.php new file mode 100644 index 000000000..a1833919d --- /dev/null +++ b/framework/core/src/Forum/Events/RenderView.php @@ -0,0 +1,14 @@ +view = &$view; + $this->assets = $assets; + } +} diff --git a/framework/core/src/Forum/ForumServiceProvider.php b/framework/core/src/Forum/ForumServiceProvider.php index e7d2c1ffa..5d08c9851 100644 --- a/framework/core/src/Forum/ForumServiceProvider.php +++ b/framework/core/src/Forum/ForumServiceProvider.php @@ -2,7 +2,6 @@ use Illuminate\Support\ServiceProvider; use Flarum\Support\AssetManager; -use Flarum\Forum\Events\BootForum; class ForumServiceProvider extends ServiceProvider { @@ -17,15 +16,6 @@ class ForumServiceProvider extends ServiceProvider $this->loadViewsFrom($root.'/views', 'flarum.forum'); - $assetManager = $this->app['flarum.forum.assetManager']; - - $assetManager->addFile([ - $root.'/js/forum/dist/app.js', - $root.'/less/forum/app.less' - ]); - - event(new BootForum($this->app)); - $this->publishes([ $root.'/public/fonts' => public_path('flarum/fonts') ]); diff --git a/framework/core/views/index.blade.php b/framework/core/views/index.blade.php index 87b911e5a..1a6902770 100644 --- a/framework/core/views/index.blade.php +++ b/framework/core/views/index.blade.php @@ -13,7 +13,7 @@
- {!! $layout !!} + @include($layout)