From cb5baf8953b52e060ec2dc4b0f052742c96be999 Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Sat, 2 May 2015 08:12:09 +0930 Subject: [PATCH] Add API to collect posts that were removed during an action MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- framework/core/src/Core/Models/Discussion.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/framework/core/src/Core/Models/Discussion.php b/framework/core/src/Core/Models/Discussion.php index 4211e755c..d3c26e2d9 100755 --- a/framework/core/src/Core/Models/Discussion.php +++ b/framework/core/src/Core/Models/Discussion.php @@ -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. *