What is the best way to notify about new FOSCommentBundle:Comment?

615 Views Asked by At

I have AcmeBlogBundle:BlogPost entity and use FOSCommentBundle to comment it. All works fine, I just do:

{% 
    include 'FOSCommentBundle:Thread:async.html.twig' 
        with {'id': 'blogpost' ~ blogpost.id} 
%}

And today I want to notify AcmeBlogBundle:BlogPost owner about new comments to his post. What is the best way to do this?

  1. I can save link to AcmeBlogBundle:BlogPost entity at AcmeBlogBundle:Thread (extends FOSCommentBundle:Thread) and then use it at thread persist events. But how can I save link, if Thread creates independently of BlogPost. And it's already not clean, because Thread will have dependency on BlogPost =(.
  2. I can store Thread id like blog_post_{id} and then parse it thread persist events =(.
  3. Store thread at BlogPost, but how I can to hook on creating Thread at concrete BlogPost.

And so on, and so on...

Sorry for my english, what is the best way to solve my problem?

UPD1: I have dupblicated question to https://github.com/FriendsOfSymfony/FOSCommentBundle/issues/367.

2

There are 2 best solutions below

0
On

Here is an example on how to use the event dispatcher with FOSCommentBundle.

0
On

Sorry, but I have no time and today my dirty hack solution is https://gist.github.com/krasun/5599548. Tomorrow, I'll start bounty.