From caed5392bd698c5ee5f83f1fd715fe76a74a5f2f Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Mon, 28 Nov 2016 11:35:20 +1030 Subject: [PATCH] Don't rely on a successful forum API call to enable debug mode --- framework/core/src/Http/WebApp/WebAppView.php | 12 ++++++++++-- framework/core/src/Http/WebApp/WebAppViewFactory.php | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/framework/core/src/Http/WebApp/WebAppView.php b/framework/core/src/Http/WebApp/WebAppView.php index 90f193367..5b4ffbe4f 100644 --- a/framework/core/src/Http/WebApp/WebAppView.php +++ b/framework/core/src/Http/WebApp/WebAppView.php @@ -13,6 +13,7 @@ namespace Flarum\Http\WebApp; use Flarum\Api\Client; use Flarum\Api\Serializer\AbstractSerializer; use Flarum\Asset\CompilerInterface; +use Flarum\Foundation\Application; use Flarum\Locale\JsCompiler; use Flarum\Locale\LocaleManager; use Illuminate\View\Factory; @@ -134,6 +135,11 @@ class WebAppView */ protected $userSerializer; + /** + * @var Application + */ + protected $app; + /** * @param string $layout * @param WebAppAssets $assets @@ -141,8 +147,9 @@ class WebAppView * @param Factory $view * @param LocaleManager $locales * @param AbstractSerializer $userSerializer + * @param Application $app */ - public function __construct($layout, WebAppAssets $assets, Client $api, Factory $view, LocaleManager $locales, AbstractSerializer $userSerializer) + public function __construct($layout, WebAppAssets $assets, Client $api, Factory $view, LocaleManager $locales, AbstractSerializer $userSerializer, Application $app) { $this->layout = $layout; $this->api = $api; @@ -150,6 +157,7 @@ class WebAppView $this->view = $view; $this->locales = $locales; $this->userSerializer = $userSerializer; + $this->app = $app; $this->addHeadString('', 'font'); @@ -269,7 +277,7 @@ class WebAppView $this->view->share('translator', $this->locales->getTranslator()); $this->view->share('allowJs', ! array_get($request->getQueryParams(), 'nojs')); $this->view->share('forum', array_get($forum, 'data')); - $this->view->share('debug', array_get($forum, 'data.attributes.debug')); + $this->view->share('debug', $this->app->inDebugMode()); $view = $this->view->file(__DIR__.'/../../../views/app.blade.php'); diff --git a/framework/core/src/Http/WebApp/WebAppViewFactory.php b/framework/core/src/Http/WebApp/WebAppViewFactory.php index 75def011d..b4a8d64cc 100644 --- a/framework/core/src/Http/WebApp/WebAppViewFactory.php +++ b/framework/core/src/Http/WebApp/WebAppViewFactory.php @@ -12,6 +12,7 @@ namespace Flarum\Http\WebApp; use Flarum\Api\Client; use Flarum\Api\Serializer\CurrentUserSerializer; +use Flarum\Foundation\Application; use Flarum\Locale\LocaleManager; use Illuminate\Contracts\View\Factory; @@ -37,18 +38,25 @@ class WebAppViewFactory */ protected $userSerializer; + /** + * @var Application + */ + protected $app; + /** * @param Client $api * @param Factory $view * @param LocaleManager $locales * @param CurrentUserSerializer $userSerializer + * @param Application $app */ - public function __construct(Client $api, Factory $view, LocaleManager $locales, CurrentUserSerializer $userSerializer) + public function __construct(Client $api, Factory $view, LocaleManager $locales, CurrentUserSerializer $userSerializer, Application $app) { $this->api = $api; $this->view = $view; $this->locales = $locales; $this->userSerializer = $userSerializer; + $this->app = $app; } /** @@ -58,6 +66,6 @@ class WebAppViewFactory */ public function make($layout, WebAppAssets $assets) { - return new WebAppView($layout, $assets, $this->api, $this->view, $this->locales, $this->userSerializer); + return new WebAppView($layout, $assets, $this->api, $this->view, $this->locales, $this->userSerializer, $this->app); } }