mirror of
https://github.com/flarum/framework.git
synced 2024-12-02 15:03:44 +08:00
Add API to collect posts that were removed during an action
This is useful for both the Sticky and Categories extensions, where if you sticky a discussion and then immediately unsticky it, or if you move it to a category and then immediately move it back, the last “activity” post will be removed.
This commit is contained in:
parent
40715203a5
commit
cb5baf8953
|
@ -49,6 +49,13 @@ class Discussion extends Model
|
|||
*/
|
||||
public $addedPosts = [];
|
||||
|
||||
/**
|
||||
* An array of posts that have been removed during this request.
|
||||
*
|
||||
* @var \Flarum\Core\Models\Post[]
|
||||
*/
|
||||
public $removedPosts = [];
|
||||
|
||||
/**
|
||||
* The user for which the state relationship should be loaded.
|
||||
*
|
||||
|
@ -166,6 +173,18 @@ class Discussion extends Model
|
|||
$this->addedPosts[] = $post;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify that a post was removed from this discussion during this
|
||||
* request for later retrieval.
|
||||
*
|
||||
* @param \Flarum\Core\Models\Post $post
|
||||
* @return void
|
||||
*/
|
||||
public function postWasRemoved(Post $post)
|
||||
{
|
||||
$this->removedPosts[] = $post->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the relationship with the discussion's posts.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue
Block a user