diff --git a/Component/Dispatcher/ForumEvents.php b/Component/Dispatcher/ForumEvents.php index ac7b08a..b148a19 100644 --- a/Component/Dispatcher/ForumEvents.php +++ b/Component/Dispatcher/ForumEvents.php @@ -710,6 +710,15 @@ final class ForumEvents */ const USER_POST_EDIT_INITIALISE = 'ccdn_forum.user.post.edit.initialise'; + /** + * + * The USER_POST_CREATE_SUCCESS event occurs when the post create process is successful before persisting. + * + * This event allows you to modify the values of the post entity object after form submission before persisting. + * The event listener method receives a CCDNForum\ForumBundle\Component\Dispatcher\Event\UserPostEvent instance. + */ + const USER_POST_CREATE_SUCCESS = 'ccdn_forum.user.post.create.success'; + /** * * The USER_POST_EDIT_SUCCESS event occurs when the post edit process is successful before persisting. diff --git a/Form/Handler/User/Post/PostCreateFormHandler.php b/Form/Handler/User/Post/PostCreateFormHandler.php index a14357e..2dff488 100644 --- a/Form/Handler/User/Post/PostCreateFormHandler.php +++ b/Form/Handler/User/Post/PostCreateFormHandler.php @@ -18,6 +18,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface ; use CCDNForum\ForumBundle\Component\Dispatcher\ForumEvents; +use CCDNForum\ForumBundle\Component\Dispatcher\Event\UserPostEvent; use CCDNForum\ForumBundle\Component\Dispatcher\Event\UserTopicEvent; use CCDNForum\ForumBundle\Component\Dispatcher\Event\UserTopicFloodEvent; use CCDNForum\ForumBundle\Form\Handler\BaseFormHandler; @@ -209,6 +210,7 @@ protected function onSuccess(Post $post) $post->setDeleted(false); $this->dispatcher->dispatch(ForumEvents::USER_TOPIC_REPLY_SUCCESS, new UserTopicEvent($this->request, $post->getTopic())); + $this->dispatcher->dispatch(ForumEvents::USER_POST_CREATE_SUCCESS, new UserPostEvent($this->request, $post)); $this->postModel->savePost($post);