mirror of
https://github.com/flarum/framework.git
synced 2024-11-25 09:25:28 +08:00
Convert subscriber to listener, eliminating compat-style extender
This commit is contained in:
parent
99e73a38a9
commit
a9e729401b
|
@ -16,8 +16,9 @@ use Flarum\Likes\Event\PostWasUnliked;
|
||||||
use Flarum\Likes\Listener;
|
use Flarum\Likes\Listener;
|
||||||
use Flarum\Likes\Notification\PostLikedBlueprint;
|
use Flarum\Likes\Notification\PostLikedBlueprint;
|
||||||
use Flarum\Post\Post;
|
use Flarum\Post\Post;
|
||||||
|
use Flarum\Post\Event\Deleted;
|
||||||
|
use Flarum\Post\Event\Saving;
|
||||||
use Flarum\User\User;
|
use Flarum\User\User;
|
||||||
use Illuminate\Contracts\Events\Dispatcher;
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
(new Extend\Frontend('forum'))
|
(new Extend\Frontend('forum'))
|
||||||
|
@ -55,9 +56,7 @@ return [
|
||||||
|
|
||||||
(new Extend\Event())
|
(new Extend\Event())
|
||||||
->listen(PostWasLiked::class, Listener\SendNotificationWhenPostIsLiked::class)
|
->listen(PostWasLiked::class, Listener\SendNotificationWhenPostIsLiked::class)
|
||||||
->listen(PostWasUnliked::class, Listener\SendNotificationWhenPostIsUnliked::class),
|
->listen(PostWasUnliked::class, Listener\SendNotificationWhenPostIsUnliked::class)
|
||||||
|
->listen(Deleted::class, [Listener\SaveLikesToDatabase::class, 'whenPostIsDeleted'])
|
||||||
function (Dispatcher $events) {
|
->listen(Saving::class, [Listener\SaveLikesToDatabase::class, 'whenPostIsSaving']),
|
||||||
$events->subscribe(Listener\SaveLikesToDatabase::class);
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
|
@ -13,19 +13,9 @@ use Flarum\Likes\Event\PostWasLiked;
|
||||||
use Flarum\Likes\Event\PostWasUnliked;
|
use Flarum\Likes\Event\PostWasUnliked;
|
||||||
use Flarum\Post\Event\Deleted;
|
use Flarum\Post\Event\Deleted;
|
||||||
use Flarum\Post\Event\Saving;
|
use Flarum\Post\Event\Saving;
|
||||||
use Illuminate\Contracts\Events\Dispatcher;
|
|
||||||
|
|
||||||
class SaveLikesToDatabase
|
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
|
* @param Saving $event
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue
Block a user