diff --git a/extensions/pusher/bootstrap.php b/extensions/pusher/bootstrap.php index 5fe44849c..52f12690c 100644 --- a/extensions/pusher/bootstrap.php +++ b/extensions/pusher/bootstrap.php @@ -9,11 +9,19 @@ * file that was distributed with this source code. */ +use Flarum\Extend; use Flarum\Pusher\Listener; use Illuminate\Contracts\Events\Dispatcher; -return function (Dispatcher $events) { - $events->subscribe(Listener\AddClientAssets::class); - $events->subscribe(Listener\AddPusherApi::class); - $events->subscribe(Listener\PushNewPosts::class); -}; +return [ + (new Extend\Assets('forum')) + ->defaultAssets(__DIR__) + ->bootstrapper('flarum/pusher/main'), + (new Extend\Assets('admin')) + ->asset(__DIR__.'/js/admin/dist/extension.js') + ->bootstrapper('flarum/pusher/main'), + function (Dispatcher $events) { + $events->subscribe(Listener\AddPusherApi::class); + $events->subscribe(Listener\PushNewPosts::class); + }, +]; diff --git a/extensions/pusher/src/Listener/AddClientAssets.php b/extensions/pusher/src/Listener/AddClientAssets.php deleted file mode 100644 index 8535685bd..000000000 --- a/extensions/pusher/src/Listener/AddClientAssets.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Flarum\Pusher\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']); - } - - /** - * @param Rendering $event - */ - public function addAssets(Rendering $event) - { - if ($event->isForum()) { - $event->addAssets([ - __DIR__.'/../../js/forum/dist/extension.js', - __DIR__.'/../../less/forum/extension.less' - ]); - $event->addBootstrapper('flarum/pusher/main'); - } - - if ($event->isAdmin()) { - $event->addAssets([ - __DIR__.'/../../js/admin/dist/extension.js' - ]); - $event->addBootstrapper('flarum/pusher/main'); - } - } -}