1
0
mirror of https://github.com/flarum/core.git synced 2025-08-09 01:46:35 +02:00

Get rid of event subscribers that resolve services too early

Refs flarum/core#1578.
This commit is contained in:
Franz Liedke
2018-12-15 16:58:00 +01:00
parent 6ac090c0cb
commit c0f08ff907
3 changed files with 57 additions and 50 deletions

View File

@@ -9,8 +9,13 @@
* file that was distributed with this source code.
*/
use Flarum\Api\Serializer\PostSerializer;
use Flarum\Event\ConfigureNotificationTypes;
use Flarum\Extend;
use Flarum\Likes\Event\PostWasLiked;
use Flarum\Likes\Event\PostWasUnliked;
use Flarum\Likes\Listener;
use Flarum\Likes\Notification\PostLikedBlueprint;
use Illuminate\Contracts\Events\Dispatcher;
return [
@@ -24,6 +29,11 @@ return [
function (Dispatcher $events) {
$events->subscribe(Listener\AddPostLikesRelationship::class);
$events->subscribe(Listener\SaveLikesToDatabase::class);
$events->subscribe(Listener\SendNotificationWhenPostIsLiked::class);
$events->listen(ConfigureNotificationTypes::class, function (ConfigureNotificationTypes $event) {
$event->add(PostLikedBlueprint::class, PostSerializer::class, ['alert']);
});
$events->listen(PostWasLiked::class, Listener\SendNotificationWhenPostIsLiked::class);
$events->listen(PostWasUnliked::class, Listener\SendNotificationWhenPostIsUnliked::class);
},
];