diff --git a/extensions/likes/extend.php b/extensions/likes/extend.php index c6d1d30ff..f6c6a865b 100644 --- a/extensions/likes/extend.php +++ b/extensions/likes/extend.php @@ -16,8 +16,9 @@ use Flarum\Likes\Event\PostWasUnliked; use Flarum\Likes\Listener; use Flarum\Likes\Notification\PostLikedBlueprint; use Flarum\Post\Post; +use Flarum\Post\Event\Deleted; +use Flarum\Post\Event\Saving; use Flarum\User\User; -use Illuminate\Contracts\Events\Dispatcher; return [ (new Extend\Frontend('forum')) @@ -55,9 +56,7 @@ return [ (new Extend\Event()) ->listen(PostWasLiked::class, Listener\SendNotificationWhenPostIsLiked::class) - ->listen(PostWasUnliked::class, Listener\SendNotificationWhenPostIsUnliked::class), - - function (Dispatcher $events) { - $events->subscribe(Listener\SaveLikesToDatabase::class); - }, + ->listen(PostWasUnliked::class, Listener\SendNotificationWhenPostIsUnliked::class) + ->listen(Deleted::class, [Listener\SaveLikesToDatabase::class, 'whenPostIsDeleted']) + ->listen(Saving::class, [Listener\SaveLikesToDatabase::class, 'whenPostIsSaving']), ]; diff --git a/extensions/likes/src/Listener/SaveLikesToDatabase.php b/extensions/likes/src/Listener/SaveLikesToDatabase.php index 516b42f73..40e03b050 100755 --- a/extensions/likes/src/Listener/SaveLikesToDatabase.php +++ b/extensions/likes/src/Listener/SaveLikesToDatabase.php @@ -13,19 +13,9 @@ use Flarum\Likes\Event\PostWasLiked; use Flarum\Likes\Event\PostWasUnliked; use Flarum\Post\Event\Deleted; use Flarum\Post\Event\Saving; -use Illuminate\Contracts\Events\Dispatcher; class SaveLikesToDatabase { - /** - * @param Dispatcher $events - */ - public function subscribe(Dispatcher $events) - { - $events->listen(Saving::class, [$this, 'whenPostIsSaving']); - $events->listen(Deleted::class, [$this, 'whenPostIsDeleted']); - } - /** * @param Saving $event */