src/PHPDish/Bundle/UserBundle/Controller/UserController.php
public function followAction($username)
    {
        $this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED');
        $manager = $this->getUserManager();
        $user = $manager->findUserByName($username);
        $view = $this->view();
        try {
            $manager->followUser($user, $this->getUser());
            $view->setStatusCode(static::HTTP_CREATED)->setData([
                'follower_count' => $user->getFollowerCount(),
            ]);
        } catch (\Exception $exception) {
            $view->setStatusCode(static::HTTP_BAD_REQUEST)
                ->setData([
                    'error' => $exception->getMessage(),
                ]);
        }

        return $this->handleView($view);
    }
public function followAction($username)
    {
        $this->denyAccessUnlessGranted('IS_AUTHENTICATED_REMEMBERED');
        $manager = $this->getUserManager();
        $user = $manager->findUserByName($username);
        $view = $this->view();
        try {
            $manager->followUser($user, $this->getUser());
            $view->setStatusCode(static::HTTP_CREATED)->setData([
                'follower_count' => $user->getFollowerCount(),
            ]);
        } catch (\Exception $exception) {
            $view->setStatusCode(static::HTTP_BAD_REQUEST)
                ->setData([
                    'error' => $exception->getMessage(),
                ]);
        }

        return $this->handleView($view);
    }
@Route("/users/{username}/followers", name="follower_add")
@Method("POST")

@param string $username

@return Response