protected function createSupportedJsonResponse($data, $statusCode = 200)
    {
        $request = $this->getRequest();
        $response = new JsonResponse($data, $statusCode);
        $response->headers->set('Vary', 'Accept');

        if (!in_array('application/json', $request->getAcceptableContentTypes(), true)) {
            $response->headers->set('Content-type', 'text/plain');
        }

        return $response;
    }
protected function createSupportedJsonResponse($data, $statusCode = 200)
    {
        $request = $this->getRequest();
        $response = new JsonResponse($data, $statusCode);
        $response->headers->set('Vary', 'Accept');

        if (!in_array('application/json', $request->getAcceptableContentTypes(), true)) {
            $response->headers->set('Content-type', 'text/plain');
        }

        return $response;
    }
protected function createSupportedJsonResponse ( $ data , $ statusCode = 200 ) { $ request = $ this -> getRequest ( ) ; $ response = new JsonResponse ( $ data , $ statusCode ) ; $ response -> headers -> set ( 'Vary' , 'Accept' ) ; if ( ! in_array ( 'application/json' , $ request -> getAcceptableContentTypes ( ) , true ) ) { $ response -> headers -> set ( 'Content-type' , 'text/plain' ) ; } return $ response ; }
Creates and returns a JsonResponse with the given data.

On top of that, if the client does not support the application/json type,
then the content type of the response will be set to text/plain instead.

@param mixed $data
@param int   $statusCode

@return JsonResponse
Creates and returns a JsonResponse with the given data .