private function processApiQuery(array $query)
    {
        $query += array(
            'params' => array(),
            'id' => null
        );

        if (empty($query['method'])) {
            throw new MissingMethodException('Missing "method" parameter in query.');
        }

        if ($query['id'] !== null && !is_scalar($query['id'])) {
            throw new InvalidIdException('The "id" parameter must be a scalar.');
        }

        if (!is_scalar($query['method'])) {
            throw new InvalidMethodException('The "method" parameter must be a scalar.');
        }

        if (!is_array($query['params'])) {
            throw new InvalidParametersException('Input parameters must be a array.');
        }

        $this->requestId = $query['id'];

        $apiResponse = $this->handler->handle($query['method'], $query['params']);

        if ($apiResponse instanceof EmptyResponseInterface) {
            if ($apiResponse instanceof ResponseInterface) {
                return new SfResponse('', $apiResponse->getHttpStatusCode(), $apiResponse->getHeaders()->all());
            } else {
                return new SfResponse('');
            }
        }

        $data = array(
            'jsonrpc' => self::JSON_RPC_VERSION,
            'result' => $apiResponse->getData(),
            'id' => $query['id']
        );

        return new JsonResponse($data, $apiResponse->getHttpStatusCode(), $apiResponse->getHeaders()->all());
    }
private function processApiQuery(array $query)
    {
        $query += array(
            'params' => array(),
            'id' => null
        );

        if (empty($query['method'])) {
            throw new MissingMethodException('Missing "method" parameter in query.');
        }

        if ($query['id'] !== null && !is_scalar($query['id'])) {
            throw new InvalidIdException('The "id" parameter must be a scalar.');
        }

        if (!is_scalar($query['method'])) {
            throw new InvalidMethodException('The "method" parameter must be a scalar.');
        }

        if (!is_array($query['params'])) {
            throw new InvalidParametersException('Input parameters must be a array.');
        }

        $this->requestId = $query['id'];

        $apiResponse = $this->handler->handle($query['method'], $query['params']);

        if ($apiResponse instanceof EmptyResponseInterface) {
            if ($apiResponse instanceof ResponseInterface) {
                return new SfResponse('', $apiResponse->getHttpStatusCode(), $apiResponse->getHeaders()->all());
            } else {
                return new SfResponse('');
            }
        }

        $data = array(
            'jsonrpc' => self::JSON_RPC_VERSION,
            'result' => $apiResponse->getData(),
            'id' => $query['id']
        );

        return new JsonResponse($data, $apiResponse->getHttpStatusCode(), $apiResponse->getHeaders()->all());
    }
private function processApiQuery ( array $ query ) { $ query += array ( 'params' => array ( ) , 'id' => null ) ; if ( empty ( $ query [ 'method' ] ) ) { throw new MissingMethodException ( 'Missing "method" parameter in query.' ) ; } if ( $ query [ 'id' ] !== null && ! is_scalar ( $ query [ 'id' ] ) ) { throw new InvalidIdException ( 'The "id" parameter must be a scalar.' ) ; } if ( ! is_scalar ( $ query [ 'method' ] ) ) { throw new InvalidMethodException ( 'The "method" parameter must be a scalar.' ) ; } if ( ! is_array ( $ query [ 'params' ] ) ) { throw new InvalidParametersException ( 'Input parameters must be a array.' ) ; } $ this -> requestId = $ query [ 'id' ] ; $ apiResponse = $ this -> handler -> handle ( $ query [ 'method' ] , $ query [ 'params' ] ) ; if ( $ apiResponse instanceof EmptyResponseInterface ) { if ( $ apiResponse instanceof ResponseInterface ) { return new SfResponse ( '' , $ apiResponse -> getHttpStatusCode ( ) , $ apiResponse -> getHeaders ( ) -> all ( ) ) ; } else { return new SfResponse ( '' ) ; } } $ data = array ( 'jsonrpc' => self :: JSON_RPC_VERSION , 'result' => $ apiResponse -> getData ( ) , 'id' => $ query [ 'id' ] ) ; return new JsonResponse ( $ data , $ apiResponse -> getHttpStatusCode ( ) , $ apiResponse -> getHeaders ( ) -> all ( ) ) ; }
Process api query

@param array $query

@return JsonResponse

@throws \Exception
Process api query