mergePost() public method

The merge logic is delegated to the new post. (As an example, a DiscussionRenamedPost will merge if adjacent to another DiscussionRenamedPost, and delete if the title has been reverted completely.)
public mergePost ( Flarum\Core\Post\MergeableInterface $post ) : Post
$post Flarum\Core\Post\MergeableInterface The post to save.
return Post The resulting post. It may or may not be the same post as was originally intended to be saved. It also may not exist, if the merge logic resulted in deletion.
 /**
  * @param Discussion $discussion
  * @param User $user
  * @param $isLocked
  */
 protected function lockedChanged(Discussion $discussion, User $user, $isLocked)
 {
     $post = DiscussionLockedPost::reply($discussion->id, $user->id, $isLocked);
     $post = $discussion->mergePost($post);
     if ($discussion->start_user_id !== $user->id) {
         $notification = new DiscussionLockedBlueprint($post);
         $this->notifications->sync($notification, $post->exists ? [$discussion->startUser] : []);
     }
 }
 /**
  * @param Discussion $discussion
  * @param User $user
  * @param bool $isSticky
  */
 protected function stickyChanged(Discussion $discussion, User $user, $isSticky)
 {
     $post = DiscussionStickiedPost::reply($discussion->id, $user->id, $isSticky);
     $discussion->mergePost($post);
 }