mirror of
https://github.com/flarum/core.git
synced 2025-08-01 14:10:37 +02:00
Run discussion events after first post is created
This commit is contained in:
@@ -34,16 +34,19 @@ class StartDiscussionCommandHandler
|
|||||||
|
|
||||||
$discussion->save();
|
$discussion->save();
|
||||||
|
|
||||||
$this->dispatchEventsFor($discussion);
|
|
||||||
|
|
||||||
// Now that the discussion has been created, we can add the first post.
|
// Now that the discussion has been created, we can add the first post.
|
||||||
// For now we will do this by running the PostReply command, but as this
|
// We will do this by running the PostReply command.
|
||||||
// will trigger a domain event that is slightly semantically incorrect
|
|
||||||
// in this situation (PostWasPosted), we may need to reconsider someday.
|
|
||||||
$post = $this->bus->dispatch(
|
$post = $this->bus->dispatch(
|
||||||
new PostReplyCommand($discussion->id, $command->user, $command->data)
|
new PostReplyCommand($discussion->id, $command->user, $command->data)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Before we dispatch events, refresh our discussion instance's
|
||||||
|
// attributes as posting the reply will have changed some of them (e.g.
|
||||||
|
// last_time.)
|
||||||
|
$discussion->setRawAttributes($post->discussion->getAttributes(), true);
|
||||||
|
|
||||||
|
$this->dispatchEventsFor($discussion);
|
||||||
|
|
||||||
return $post->discussion;
|
return $post->discussion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user