From 9c6ef9e043838fdbdf324527638e7d0666302259 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Tue, 16 Jan 2018 23:20:02 +0100 Subject: [PATCH] Adapt new bootstrap format, use Asset extender --- extensions/suspend/bootstrap.php | 22 ++++++--- .../suspend/src/Listener/AddClientAssets.php | 45 ------------------- 2 files changed, 15 insertions(+), 52 deletions(-) delete mode 100644 extensions/suspend/src/Listener/AddClientAssets.php diff --git a/extensions/suspend/bootstrap.php b/extensions/suspend/bootstrap.php index 74d3f0c8a..4b489505d 100644 --- a/extensions/suspend/bootstrap.php +++ b/extensions/suspend/bootstrap.php @@ -9,15 +9,23 @@ * file that was distributed with this source code. */ +use Flarum\Extend; use Flarum\Suspend\Access; use Flarum\Suspend\Listener; use Illuminate\Contracts\Events\Dispatcher; -return function (Dispatcher $events) { - $events->subscribe(Listener\AddClientAssets::class); - $events->subscribe(Listener\AddUserSuspendAttributes::class); - $events->subscribe(Listener\RevokeAccessFromSuspendedUsers::class); - $events->subscribe(Listener\SaveSuspensionToDatabase::class); +return [ + (new Extend\Assets('forum')) + ->defaultAssets(__DIR__) + ->bootstrapper('flarum/suspend/main'), + (new Extend\Assets('admin')) + ->defaultAssets(__DIR__) + ->bootstrapper('flarum/suspend/main'), + function (Dispatcher $events) { + $events->subscribe(Listener\AddUserSuspendAttributes::class); + $events->subscribe(Listener\RevokeAccessFromSuspendedUsers::class); + $events->subscribe(Listener\SaveSuspensionToDatabase::class); - $events->subscribe(Access\UserPolicy::class); -}; + $events->subscribe(Access\UserPolicy::class); + } +]; diff --git a/extensions/suspend/src/Listener/AddClientAssets.php b/extensions/suspend/src/Listener/AddClientAssets.php deleted file mode 100644 index 5db7850ee..000000000 --- a/extensions/suspend/src/Listener/AddClientAssets.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Flarum\Suspend\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', - __DIR__.'/../../less/forum/extension.less' - ]); - $event->addBootstrapper('flarum/suspend/main'); - } - - if ($event->isAdmin()) { - $event->addAssets([ - __DIR__.'/../../js/admin/dist/extension.js', - __DIR__.'/../../less/admin/extension.less' - ]); - $event->addBootstrapper('flarum/suspend/main'); - } - } -}