src/PHPDish/Bundle/ForumBundle/Service/ReplyManager.php
public function saveReply(ReplyInterface $reply)
    {
        $parsedBody = $this->bodyProcessor->process($reply->getOriginalBody());
        $reply->setUpdatedAt(Carbon::now())
            ->setBody($parsedBody);

        if ($new = !$reply->getId()) {
            $reply->getTopic()->addCommentCount(1)
                ->setLastCommentAt(Carbon::now())
                ->setLastCommentUser($reply->getUser());
        }

        $this->entityManager->persist($reply);
        $this->entityManager->flush();

        //如果是新生成的并且提及了用户则触发事件
        $mentionParser = $this->bodyProcessor->getMentionParser();
        $new && $mentionParser->getMentionedUsers() && $this->eventDispatcher->dispatch(Events::USER_MENTIONED_REPLY, new ReplyMentionUserEvent(
            $reply,
            $mentionParser->getMentionedUsers()
        ));

        return true;
    }
public function saveReply(ReplyInterface $reply)
    {
        $parsedBody = $this->bodyProcessor->process($reply->getOriginalBody());
        $reply->setUpdatedAt(Carbon::now())
            ->setBody($parsedBody);

        if ($new = !$reply->getId()) {
            $reply->getTopic()->addCommentCount(1)
                ->setLastCommentAt(Carbon::now())
                ->setLastCommentUser($reply->getUser());
        }

        $this->entityManager->persist($reply);
        $this->entityManager->flush();

        //如果是新生成的并且提及了用户则触发事件
        $mentionParser = $this->bodyProcessor->getMentionParser();
        $new && $mentionParser->getMentionedUsers() && $this->eventDispatcher->dispatch(Events::USER_MENTIONED_REPLY, new ReplyMentionUserEvent(
            $reply,
            $mentionParser->getMentionedUsers()
        ));

        return true;
    }
{@inheritdoc}