Fix class names, view namespace

This commit is contained in:
Toby Zerner 2017-12-27 16:15:21 +10:30
parent 7518578a13
commit f19e24a377
4 changed files with 16 additions and 15 deletions

View File

@ -11,8 +11,11 @@
use Flarum\Embed\Listener;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Contracts\View\Factory;
return function (Dispatcher $events) {
return function (Dispatcher $events, Factory $view) {
$events->subscribe(Listener\AddEmbedRoute::class);
$events->subscribe(Listener\FlushEmbedAssetsWhenSettingsAreChanged::class);
$view->addNamespace('flarum-embed', __DIR__.'/views');
};

View File

@ -10,9 +10,9 @@
namespace Flarum\Embed;
use Flarum\Forum\WebApp;
use Flarum\Forum\Frontend;
class EmbedWebApp extends WebApp
class EmbedFrontend extends Frontend
{
/**
* {@inheritdoc}
@ -25,7 +25,7 @@ class EmbedWebApp extends WebApp
$view->getCss()->addFile(__DIR__.'/../less/forum/extension.less');
$view->loadModule('flarum/embed/main');
$view->layout = __DIR__.'/../views/embed.blade.php';
$view->layout = 'flarum-embed::embed';
return $view;
}

View File

@ -12,7 +12,6 @@ namespace Flarum\Embed;
use Flarum\Api\Client;
use Flarum\Forum\Controller\DiscussionController;
use Flarum\Forum\Frontend;
use Flarum\Http\UrlGenerator;
use Illuminate\Contracts\Events\Dispatcher;
@ -21,7 +20,7 @@ class EmbeddedDiscussionController extends DiscussionController
/**
* {@inheritdoc}
*/
public function __construct(Frontend $frontend, Dispatcher $events, Client $api, UrlGenerator $url)
public function __construct(EmbedFrontend $frontend, Dispatcher $events, Client $api, UrlGenerator $url)
{
parent::__construct($frontend, $events, $api, $url);
}

View File

@ -10,8 +10,7 @@
namespace Flarum\Embed\Listener;
use Flarum\Embed\DiscussionController;
use Flarum\Embed\EmbedWebApp;
use Flarum\Embed\EmbedFrontend;
use Flarum\Extension\Event\Disabled;
use Flarum\Extension\Event\Enabled;
use Flarum\Settings\Event\Saved;
@ -20,16 +19,16 @@ use Illuminate\Contracts\Events\Dispatcher;
class FlushEmbedAssetsWhenSettingsAreChanged
{
/**
* @var DiscussionController
* @var EmbedFrontend
*/
protected $webApp;
protected $frontend;
/**
* @param EmbedWebApp $webApp
* @param EmbedFrontend $frontend
*/
public function __construct(EmbedWebApp $webApp)
public function __construct(EmbedFrontend $frontend)
{
$this->webApp = $webApp;
$this->frontend = $frontend;
}
/**
@ -48,12 +47,12 @@ class FlushEmbedAssetsWhenSettingsAreChanged
public function flushCss(Saved $event)
{
if (preg_match('/^theme_|^custom_less$/i', $event->key)) {
$this->webApp->getAssets()->flushCss();
$this->frontend->getAssets()->flushCss();
}
}
public function flushAssets()
{
$this->webApp->getAssets()->flush();
$this->frontend->getAssets()->flush();
}
}