From ee07f29d5aa0748318db195dd25559c022e57651 Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Tue, 16 Jan 2018 23:26:21 +0100 Subject: [PATCH] Adapt new bootstrap format, use Asset extender --- extensions/mentions/bootstrap.php | 25 +++++++----- .../mentions/src/Listener/AddClientAssets.php | 40 ------------------- 2 files changed, 15 insertions(+), 50 deletions(-) delete mode 100755 extensions/mentions/src/Listener/AddClientAssets.php diff --git a/extensions/mentions/bootstrap.php b/extensions/mentions/bootstrap.php index 8297197de..0211447bf 100644 --- a/extensions/mentions/bootstrap.php +++ b/extensions/mentions/bootstrap.php @@ -9,18 +9,23 @@ * file that was distributed with this source code. */ +use Flarum\Extend; use Flarum\Mentions\Listener; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\View\Factory; -return function (Dispatcher $events, Factory $views) { - $events->subscribe(Listener\AddClientAssets::class); - $events->subscribe(Listener\AddPostMentionedByRelationship::class); - $events->subscribe(Listener\FormatPostMentions::class); - $events->subscribe(Listener\FormatUserMentions::class); - $events->subscribe(Listener\UpdatePostMentionsMetadata::class); - $events->subscribe(Listener\UpdateUserMentionsMetadata::class); - $events->subscribe(Listener\AddFilterByMentions::class); +return [ + (new Extend\Assets('forum')) + ->defaultAssets(__DIR__) + ->bootstrapper('flarum/mentions/main'), + function (Dispatcher $events, Factory $views) { + $events->subscribe(Listener\AddPostMentionedByRelationship::class); + $events->subscribe(Listener\FormatPostMentions::class); + $events->subscribe(Listener\FormatUserMentions::class); + $events->subscribe(Listener\UpdatePostMentionsMetadata::class); + $events->subscribe(Listener\UpdateUserMentionsMetadata::class); + $events->subscribe(Listener\AddFilterByMentions::class); - $views->addNamespace('flarum-mentions', __DIR__.'/views'); -}; + $views->addNamespace('flarum-mentions', __DIR__.'/views'); + }, +]; diff --git a/extensions/mentions/src/Listener/AddClientAssets.php b/extensions/mentions/src/Listener/AddClientAssets.php deleted file mode 100755 index ea57fc5ff..000000000 --- a/extensions/mentions/src/Listener/AddClientAssets.php +++ /dev/null @@ -1,40 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Flarum\Mentions\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/mentions/main'); - } - } -}