QCharts/ApiBundle/Controller/UserController.php
public function getUsersAction(Request $request)
    {
        $authChecker = $this->get("security.authorization_checker");

        $roles = $this->getParameter('qcharts.user_roles');

        if (!$authChecker->isGranted($roles["super_admin"]))
        {
            return new JsonResponse(ApiController::getNotValidCredentials());
        }

        $userService = $this->get("qcharts.user_service");
        try
        {
            $role = $request->query->get('developer', null);
            $encoding = $request->query->get('_format', 'json');

            $userService->setEncoding($encoding);
            $userService->setRole($role);
            $users = $userService->getDetails($this->getUser());

            $response = new Response($users);
            $response->headers->set('Content-Type', "application/{$userService->getEncoding()}");
            return $response;
        }
        catch(InstanceNotFoundException $e)
        {
            return new JsonResponse([
                "status"=>$e->getCode(),
                "text"=>$e->getMessage()
            ]);
        }
    }
public function getUsersAction(Request $request)
    {
        $authChecker = $this->get("security.authorization_checker");

        $roles = $this->getParameter('qcharts.user_roles');

        if (!$authChecker->isGranted($roles["super_admin"]))
        {
            return new JsonResponse(ApiController::getNotValidCredentials());
        }

        $userService = $this->get("qcharts.user_service");
        try
        {
            $role = $request->query->get('developer', null);
            $encoding = $request->query->get('_format', 'json');

            $userService->setEncoding($encoding);
            $userService->setRole($role);
            $users = $userService->getDetails($this->getUser());

            $response = new Response($users);
            $response->headers->set('Content-Type', "application/{$userService->getEncoding()}");
            return $response;
        }
        catch(InstanceNotFoundException $e)
        {
            return new JsonResponse([
                "status"=>$e->getCode(),
                "text"=>$e->getMessage()
            ]);
        }
    }
ApiDoc(
description = "Returns the users and the information",
parameters = {
{
"name" = "developer",
"dataType" = "boolean",
"required" = false,
"description" = "Returns the users with the given role, not given returns all users"
},
{
"name" = "_format",
"dataType" = "string",
"required" = false,
"description" = "The response is by the requested format, options: json or xml"
}
},
statusCodes = {
200 = "Success",
404 = "No users with the given query was found"
}
)
@param Request $request
@return JsonResponse