From a4c42dcfff6fc8b083003950fa9ad73b61a0a414 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Tue, 16 Jan 2018 23:19:29 +0100 Subject: [PATCH] Adapt new bootstrap format, use Asset extender --- extensions/sticky/bootstrap.php | 22 ++++++--- .../sticky/src/Listener/AddClientAssets.php | 47 ------------------- 2 files changed, 15 insertions(+), 54 deletions(-) delete mode 100755 extensions/sticky/src/Listener/AddClientAssets.php diff --git a/extensions/sticky/bootstrap.php b/extensions/sticky/bootstrap.php index 19076c02e..e800e6908 100644 --- a/extensions/sticky/bootstrap.php +++ b/extensions/sticky/bootstrap.php @@ -9,13 +9,21 @@ * file that was distributed with this source code. */ +use Flarum\Extend; use Flarum\Sticky\Listener; use Illuminate\Contracts\Events\Dispatcher; -return function (Dispatcher $events) { - $events->subscribe(Listener\AddApiAttributes::class); - $events->subscribe(Listener\AddClientAssets::class); - $events->subscribe(Listener\CreatePostWhenDiscussionIsStickied::class); - $events->subscribe(Listener\PinStickiedDiscussionsToTop::class); - $events->subscribe(Listener\SaveStickyToDatabase::class); -}; +return [ + (new Extend\Assets('forum')) + ->defaultAssets(__DIR__) + ->bootstrapper('flarum/sticky/main'), + (new Extend\Assets('admin')) + ->asset(__DIR__.'/js/admin/dist/extension.js') + ->bootstrapper('flarum/sticky/main'), + function (Dispatcher $events) { + $events->subscribe(Listener\AddApiAttributes::class); + $events->subscribe(Listener\CreatePostWhenDiscussionIsStickied::class); + $events->subscribe(Listener\PinStickiedDiscussionsToTop::class); + $events->subscribe(Listener\SaveStickyToDatabase::class); + }, +]; diff --git a/extensions/sticky/src/Listener/AddClientAssets.php b/extensions/sticky/src/Listener/AddClientAssets.php deleted file mode 100755 index 2fd1f3981..000000000 --- a/extensions/sticky/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\Sticky\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/sticky/main'); - } - - if ($event->isAdmin()) { - $event->addAssets([ - __DIR__.'/../../js/admin/dist/extension.js' - ]); - $event->addBootstrapper('flarum/sticky/main'); - } - } -}