Don't rely on a successful forum API call to enable debug mode

This commit is contained in:
Toby Zerner 2016-11-28 11:35:20 +10:30
parent 39adb0f223
commit caed5392bd
2 changed files with 20 additions and 4 deletions

View File

@ -13,6 +13,7 @@ namespace Flarum\Http\WebApp;
use Flarum\Api\Client; use Flarum\Api\Client;
use Flarum\Api\Serializer\AbstractSerializer; use Flarum\Api\Serializer\AbstractSerializer;
use Flarum\Asset\CompilerInterface; use Flarum\Asset\CompilerInterface;
use Flarum\Foundation\Application;
use Flarum\Locale\JsCompiler; use Flarum\Locale\JsCompiler;
use Flarum\Locale\LocaleManager; use Flarum\Locale\LocaleManager;
use Illuminate\View\Factory; use Illuminate\View\Factory;
@ -134,6 +135,11 @@ class WebAppView
*/ */
protected $userSerializer; protected $userSerializer;
/**
* @var Application
*/
protected $app;
/** /**
* @param string $layout * @param string $layout
* @param WebAppAssets $assets * @param WebAppAssets $assets
@ -141,8 +147,9 @@ class WebAppView
* @param Factory $view * @param Factory $view
* @param LocaleManager $locales * @param LocaleManager $locales
* @param AbstractSerializer $userSerializer * @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->layout = $layout;
$this->api = $api; $this->api = $api;
@ -150,6 +157,7 @@ class WebAppView
$this->view = $view; $this->view = $view;
$this->locales = $locales; $this->locales = $locales;
$this->userSerializer = $userSerializer; $this->userSerializer = $userSerializer;
$this->app = $app;
$this->addHeadString('<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700,600">', 'font'); $this->addHeadString('<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,400,700,600">', 'font');
@ -269,7 +277,7 @@ class WebAppView
$this->view->share('translator', $this->locales->getTranslator()); $this->view->share('translator', $this->locales->getTranslator());
$this->view->share('allowJs', ! array_get($request->getQueryParams(), 'nojs')); $this->view->share('allowJs', ! array_get($request->getQueryParams(), 'nojs'));
$this->view->share('forum', array_get($forum, 'data')); $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'); $view = $this->view->file(__DIR__.'/../../../views/app.blade.php');

View File

@ -12,6 +12,7 @@ namespace Flarum\Http\WebApp;
use Flarum\Api\Client; use Flarum\Api\Client;
use Flarum\Api\Serializer\CurrentUserSerializer; use Flarum\Api\Serializer\CurrentUserSerializer;
use Flarum\Foundation\Application;
use Flarum\Locale\LocaleManager; use Flarum\Locale\LocaleManager;
use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\Factory;
@ -37,18 +38,25 @@ class WebAppViewFactory
*/ */
protected $userSerializer; protected $userSerializer;
/**
* @var Application
*/
protected $app;
/** /**
* @param Client $api * @param Client $api
* @param Factory $view * @param Factory $view
* @param LocaleManager $locales * @param LocaleManager $locales
* @param CurrentUserSerializer $userSerializer * @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->api = $api;
$this->view = $view; $this->view = $view;
$this->locales = $locales; $this->locales = $locales;
$this->userSerializer = $userSerializer; $this->userSerializer = $userSerializer;
$this->app = $app;
} }
/** /**
@ -58,6 +66,6 @@ class WebAppViewFactory
*/ */
public function make($layout, WebAppAssets $assets) 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);
} }
} }