-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Flarum events to purge LSCache to support CLI and HTTP contexts (#30
- Loading branch information
Showing
43 changed files
with
969 additions
and
604 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
...Compatibility/ClarkWinkelmann/AuthorChange/ClarkWinkelmannAuthorChangeEventSubscriber.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
namespace ACPL\FlarumLSCache\Compatibility\ClarkWinkelmann\AuthorChange; | ||
|
||
use ACPL\FlarumLSCache\Listener\{AbstractCachePurgeSubscriber, DiscussionCachePurgeTrait}; | ||
use ClarkWinkelmann\AuthorChange\Event\{ | ||
DiscussionCreateDateChanged, | ||
DiscussionUserChanged, | ||
PostCreateDateChanged, | ||
PostEditDateChanged, | ||
PostUserChanged | ||
}; | ||
use Illuminate\Contracts\Events\Dispatcher; | ||
|
||
class ClarkWinkelmannAuthorChangeEventSubscriber extends AbstractCachePurgeSubscriber | ||
{ | ||
use DiscussionCachePurgeTrait; | ||
|
||
public function subscribe(Dispatcher $events): void | ||
{ | ||
$this->addPurgeListener($events, DiscussionCreateDateChanged::class, [$this, 'handleDiscussion']); | ||
$this->addPurgeListener($events, DiscussionUserChanged::class, [$this, 'handleDiscussionUserChanged']); | ||
$this->addPurgeListener($events, PostCreateDateChanged::class, [$this, 'handlePost']); | ||
$this->addPurgeListener($events, PostEditDateChanged::class, [$this, 'handlePost']); | ||
$this->addPurgeListener($events, PostUserChanged::class, [$this, 'handlePostUserChanged']); | ||
} | ||
|
||
protected function handleDiscussion(DiscussionCreateDateChanged|DiscussionUserChanged $event): void | ||
{ | ||
$this->handleDiscussionRelatedPurge(); | ||
$this->purger->addPurgeTags([ | ||
"discussion_{$event->discussion->id}", | ||
"user_{$event->discussion->user->id}", | ||
"user_{$event->discussion->user->username}", | ||
]); | ||
} | ||
|
||
protected function handleDiscussionUserChanged(DiscussionUserChanged $event): void | ||
{ | ||
$this->handleDiscussion($event); | ||
$this->purger->addPurgeTags([ | ||
"user_{$event->oldUser->id}", | ||
"user_{$event->oldUser->username}", | ||
]); | ||
} | ||
|
||
protected function handlePost(PostCreateDateChanged|PostEditDateChanged|PostUserChanged $event): void | ||
{ | ||
$this->purger->addPurgeTags([ | ||
"discussion_{$event->post->discussion->id}", | ||
'posts.index', | ||
"post_{$event->post->id}", | ||
"user_{$event->post->user->id}", | ||
"user_{$event->post->user->username}", | ||
]); | ||
} | ||
|
||
protected function handlePostUserChanged(PostUserChanged $event): void | ||
{ | ||
$this->handlePost($event); | ||
$this->purger->addPurgeTags([ | ||
"user_{$event->oldUser->id}", | ||
"user_{$event->oldUser->username}", | ||
]); | ||
} | ||
} |
Oops, something went wrong.