Skip to content

Commit

Permalink
refactor: simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaucau committed Sep 12, 2024
1 parent 2d7dcfe commit e79ebd9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Compatibility/SychO/MovePosts/SychOMovePostsSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ public function subscribe(Dispatcher $events): void

protected function handlePostsMoved(PostsMoved $event): void
{
$postUserTags = [];
$event->posts->each(function ($post) use (&$postUserTags) {
$cacheTags = [];
$event->posts->each(function ($post) use (&$cacheTags) {
/** @var CommentPost $post */
$postUserTags[] = "user_{$post->user->id}";
$postUserTags[] = "user_{$post->user->username}";
$cacheTags[] = "post_{$post->id}";
$cacheTags[] = "user_{$post->user->id}";
$cacheTags[] = "user_{$post->user->username}";
});

$this->purger->addPurgeTags([
Expand All @@ -30,8 +31,7 @@ protected function handlePostsMoved(PostsMoved $event): void
'discussions.index',
"discussion_{$event->sourceDiscussion->id}",
"discussion_{$event->targetDiscussion->id}",
...array_map(fn ($postId) => "post_$postId", $event->posts->pluck('id')->toArray()),
...$postUserTags,
...$cacheTags,
]);
}
}

0 comments on commit e79ebd9

Please sign in to comment.