Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'USER_POST_CREATE_SUCCESS' event after the 'USER_TOPIC_REPLY_SUCC… #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Component/Dispatcher/ForumEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions Form/Handler/User/Post/PostCreateFormHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down