src/PHPDish/Bundle/PostBundle/Controller/CategoryController.php
public function followAction($slug)
    {
        $this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED');
        $category = $this->getCategoryManager()->findCategoryBySlug($slug);

        if ($category->isCharging() && !$category->isBelongsTo($this->getUser())) { //收费专栏/电子书
            $qrCode = $this->getCategoryManager()->payForCategory($category, $this->getUser());
            $view = $this->view([
                'require_payment' => true,
                'message' => $this->get('translator')->trans('category.need_payment'),
                'qrcode' => $qrCode
            ]);
        } else {
            $this->getCategoryManager()->followCategory($category, $this->getUser());
            $view = $this->view([
                'follower_count' => $category->getFollowerCount(),
            ]);
        }

        return $this->handleView($view);
    }
public function followAction($slug)
    {
        $this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED');
        $category = $this->getCategoryManager()->findCategoryBySlug($slug);

        if ($category->isCharging() && !$category->isBelongsTo($this->getUser())) { //收费专栏/电子书
            $qrCode = $this->getCategoryManager()->payForCategory($category, $this->getUser());
            $view = $this->view([
                'require_payment' => true,
                'message' => $this->get('translator')->trans('category.need_payment'),
                'qrcode' => $qrCode
            ]);
        } else {
            $this->getCategoryManager()->followCategory($category, $this->getUser());
            $view = $this->view([
                'follower_count' => $category->getFollowerCount(),
            ]);
        }

        return $this->handleView($view);
    }
关注话题.

@Route("/categories/{slug}/followers", name="category_follow")
@Method("POST")

@param string $slug

@return Response