Adapt new bootstrap format, use Asset extender

This commit is contained in:
Franz Liedke 2018-01-16 23:17:23 +01:00
parent 250a6660b4
commit ac01d40b9a
2 changed files with 11 additions and 47 deletions

View File

@ -12,7 +12,14 @@
use Flarum\Akismet\Listener;
use Illuminate\Contracts\Events\Dispatcher;
return function (Dispatcher $events) {
$events->subscribe(Listener\AddClientAssets::class);
$events->subscribe(Listener\FilterNewPosts::class);
};
return [
(new \Flarum\Extend\Assets('forum'))
->asset(__DIR__.'/js/forum/dist/extension.js')
->bootstrapper('flarum/akismet/main'),
(new \Flarum\Extend\Assets('admin'))
->asset(__DIR__.'/js/admin/dist/extension.js')
->bootstrapper('flarum/akismet/main'),
function (Dispatcher $events) {
$events->subscribe(Listener\FilterNewPosts::class);
}
];

View File

@ -1,43 +0,0 @@
<?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flarum\Akismet\Listener;
use Flarum\Frontend\Event\Rendering;
use Illuminate\Contracts\Events\Dispatcher;
class AddClientAssets
{
/**
* @param Dispatcher $events
*/
public function subscribe(Dispatcher $events)
{
$events->listen(Rendering::class, [$this, 'addAssets']);
}
public function addAssets(Rendering $event)
{
if ($event->isForum()) {
$event->addAssets([
__DIR__.'/../../js/forum/dist/extension.js'
]);
$event->addBootstrapper('flarum/akismet/main');
}
if ($event->isAdmin()) {
$event->addAssets([
__DIR__.'/../../js/admin/dist/extension.js'
]);
$event->addBootstrapper('flarum/akismet/main');
}
}
}