From 358a19f3c1e7000104e648612eec39be3aaba1e9 Mon Sep 17 00:00:00 2001 From: Sami Mazouz Date: Tue, 8 Dec 2020 18:46:25 +0100 Subject: [PATCH] Use new extenders (#30) --- extensions/pusher/extend.php | 14 ++++--- .../pusher/src/Listener/AddPusherApi.php | 38 ------------------- 2 files changed, 8 insertions(+), 44 deletions(-) delete mode 100755 extensions/pusher/src/Listener/AddPusherApi.php diff --git a/extensions/pusher/extend.php b/extensions/pusher/extend.php index 7d5f67d96..eaf12229b 100644 --- a/extensions/pusher/extend.php +++ b/extensions/pusher/extend.php @@ -7,7 +7,6 @@ * LICENSE file that was distributed with this source code. */ -use Flarum\Api\Event\Serializing; use Flarum\Extend; use Flarum\Post\Event\Posted; use Flarum\Pusher\Api\Controller\AuthController; @@ -15,7 +14,6 @@ use Flarum\Pusher\Listener; use Flarum\Pusher\PusherNotificationDriver; use Flarum\Settings\SettingsRepositoryInterface; use Illuminate\Contracts\Container\Container; -use Illuminate\Contracts\Events\Dispatcher; return [ (new Extend\Frontend('forum')) @@ -33,7 +31,14 @@ return [ (new Extend\Notification()) ->driver('pusher', PusherNotificationDriver::class), - function (Dispatcher $events, Container $container) { + (new Extend\Settings()) + ->serializeToForum('pusherKey', 'flarum-pusher.app_key') + ->serializeToForum('pusherCluster', 'flarum-pusher.app_cluster'), + + (new Extend\Event()) + ->listen(Posted::class, Listener\PushNewPost::class), + + function (Container $container) { $container->bind(Pusher::class, function ($app) { $settings = $app->make(SettingsRepositoryInterface::class); @@ -50,8 +55,5 @@ return [ $options ); }); - - $events->listen(Posted::class, Listener\PushNewPost::class); - $events->listen(Serializing::class, Listener\AddPusherApi::class); }, ]; diff --git a/extensions/pusher/src/Listener/AddPusherApi.php b/extensions/pusher/src/Listener/AddPusherApi.php deleted file mode 100755 index f090fefe4..000000000 --- a/extensions/pusher/src/Listener/AddPusherApi.php +++ /dev/null @@ -1,38 +0,0 @@ -settings = $settings; - } - - public function handle(Serializing $event) - { - if ($event->isSerializer(ForumSerializer::class)) { - $event->attributes['pusherKey'] = $this->settings->get('flarum-pusher.app_key'); - $event->attributes['pusherCluster'] = $this->settings->get('flarum-pusher.app_cluster'); - } - } -}