Controller/AbstractRestController.php
public function renderRest(
        $request,
        $data,
        $statusCode = Response::HTTP_OK,
        $headers = []
    ) {
        $requestSerializer = $this->get('ongr_api.request_serializer');

        return new Response(
            $requestSerializer->serializeRequest($request, $data),
            $statusCode,
            array_merge(
                ['Content-Type' => 'application/' . $requestSerializer->checkAcceptHeader($request)],
                $headers
            )
        );
    }
public function renderRest(
        $request,
        $data,
        $statusCode = Response::HTTP_OK,
        $headers = []
    ) {
        $requestSerializer = $this->get('ongr_api.request_serializer');

        return new Response(
            $requestSerializer->serializeRequest($request, $data),
            $statusCode,
            array_merge(
                ['Content-Type' => 'application/' . $requestSerializer->checkAcceptHeader($request)],
                $headers
            )
        );
    }
Renders rest response.

@param Request $request
@param string  $data
@param int     $statusCode
@param array   $headers

@return Response|array