QCharts/ApiBundle/Controller/FavoriteController.php
public function removeFavoriteAction(Request $request)
    {
        $roles = $this->getParameter("qcharts.user_roles");
        $authService = $this->get("security.authorization_checker");

        $options = [];

        try
        {
            ApiController::checkCredentials($authService, $roles, "user");
            $user = $this->getUser();
            $queryId = $request->request->get("q", null);
            $queryService = $this->get("qcharts.query");
            $favService = $this->get("qcharts.core.favorite_service");

            $queryRequest = $queryService->getQueryRequestById($queryId);
            $favService->removeFavourite($user, $queryRequest);

            $options = [
                "status" => 202,
                "textStatus" => "The favorite was removed from the user's list"
            ];

        }
        catch (InstanceNotFoundException $e)
        {
            $options = [
                "status" => $e->getCode(),
                "textStatus" => $e->getMessage()
            ];
        }
        finally
        {
            return new JsonResponse($options);
        }
    }
public function removeFavoriteAction(Request $request)
    {
        $roles = $this->getParameter("qcharts.user_roles");
        $authService = $this->get("security.authorization_checker");

        $options = [];

        try
        {
            ApiController::checkCredentials($authService, $roles, "user");
            $user = $this->getUser();
            $queryId = $request->request->get("q", null);
            $queryService = $this->get("qcharts.query");
            $favService = $this->get("qcharts.core.favorite_service");

            $queryRequest = $queryService->getQueryRequestById($queryId);
            $favService->removeFavourite($user, $queryRequest);

            $options = [
                "status" => 202,
                "textStatus" => "The favorite was removed from the user's list"
            ];

        }
        catch (InstanceNotFoundException $e)
        {
            $options = [
                "status" => $e->getCode(),
                "textStatus" => $e->getMessage()
            ];
        }
        finally
        {
            return new JsonResponse($options);
        }
    }
ApiDoc(
description = "Removes the given query request from the favorites list of the user",
parameters = {
{
"name" = "q",
"required" = true,
"dataType" = "integer",
"description" = "The query Id to remove from the user's list"
}
},
statusCodes = {
202 = "The query was removed from the user's favorite list",
500 = "Error while attempting to remove the query form the user's favorite list"
}
)
@param Request $request
@return JsonResponse