/** * Reacts to topic reply events. When a topic is replied to, we want to * update the counts on the topic as well as send emails notifying the * thread participants of a new post. * * @param TopicEventInterface $event */ public function onReplyToTopic(TopicEventInterface $event) { /** @var $topic \Rhapsody\SocialBundle\Model\TopicInterface */ $topic = $event->getTopic(); /** @var $post \Rhapsody\SocialBundle\Model\PostInterface */ $post = $event->getPost(); /** @var $author \Symfony\Component\Security\Core\User\UserInterface */ $author = $event->getUser(); // ** Count the number of posts and replies for a given topic. $this->topicManager->updateCounts($topic); // ** The URL for viewing the forum post. $url = $this->router->generate('rhapsody_forum_topic_view', array('topic' => $topic->getId()), UrlGeneratorInterface::ABSOLUTE_URL); $users = $this->topicManager->findUsersByTopic($topic); foreach ($users as $user) { // ** // Only send the comment email to people OTHER THAN the person who // actually posted the comment. Why do they need to know they posted // a comment? They already do! They just posted it! [SWQ] if ($user->getId() !== $author->getId()) { /** @var $user \Symfony\Component\Security\Core\User\UserInterface */ $email = $user->email; if (!empty($email)) { $data = array('author' => $author, 'topic' => $topic, 'post' => $post, 'url' => $url, 'user' => $user); /** @var $message \Application\LorecallBundle\Model\Messaging\MessageTemplate */ $message = EmailTemplate::newInstance()->setTemplate($this->templateFactory->getTopicReplyEmailTemplate())->setTo($email)->setFrom($this->senderEmail, $this->senderName); $this->mailer->sendMessage($message, $data); } } } }
/** * Reacts to topic reply events. When a topic is replied to, we want to * update the counts on the topic as well as send emails notifying the * thread participants of a new post. * * @param TopicEventInterface $event */ public function onReplyToTopic(TopicEventInterface $event) { $topic = $event->getTopic(); $post = $event->getPost(); $author = $event->getUser(); $forum = $topic->getForum(); $url = $this->getTopicUrl($forum, $topic); $watchers = $this->topicManager->findUsersByTopic($topic); $users = $this->exclude($watchers, array($author)); $template = 'RhapsodyForumBundle:Mail:topic_reply_email.txt.twig'; $data = array('author' => $author, 'forum' => $forum, 'topic' => $topic, 'post' => $post, 'url' => $url); $this->notify($template, $data, $users); $this->generateActivity($forum, $post, $author); $this->topicManager->updateCounts($topic); $this->forumManager->updateForumActivityStats($forum, $topic, $post); }