src/PHPDish/Bundle/ForumBundle/Controller/TopicReplyController.php
public function toggleVoterAction($id)
    {
        $this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED');

        $reply = $this->getReplyManager()->findReplyById($id);
        if (!$reply) {
            throw new \InvalidArgumentException($this->get('translator')->trans('reply.not_exists'));
        }

        if ($isVoted = $reply->isVotedBy($this->getUser())) {
            $this->getReplyManager()->removeVoter($reply, $this->getUser());
        } else {
            $this->getReplyManager()->addVoter($reply, $this->getUser());
        }
        return $this->json([
            'vote_count' => $reply->getVoteCount(),
            'is_voted' => !$isVoted
        ]);
    }
public function toggleVoterAction($id)
    {
        $this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED');

        $reply = $this->getReplyManager()->findReplyById($id);
        if (!$reply) {
            throw new \InvalidArgumentException($this->get('translator')->trans('reply.not_exists'));
        }

        if ($isVoted = $reply->isVotedBy($this->getUser())) {
            $this->getReplyManager()->removeVoter($reply, $this->getUser());
        } else {
            $this->getReplyManager()->addVoter($reply, $this->getUser());
        }
        return $this->json([
            'vote_count' => $reply->getVoteCount(),
            'is_voted' => !$isVoted
        ]);
    }
切换点赞状态

@Route("/replies/{id}/voters", name="topic_reply_toggle_voter", methods={"POST"})

@param int $id