protected function getRequestQueryVariables(HTTPRequest $request)
    {
        $contentType = $request->getHeader('content-type');
        $isJson = preg_match('#^application/json\b#', $contentType);
        if ($isJson) {
            $rawBody = $request->getBody();
            $data = json_decode($rawBody ?: '', true);
            $query = isset($data['query']) ? $data['query'] : null;
            $id = isset($data['id']) ? $data['id'] : null;
            $variables = isset($data['variables']) ? (array)$data['variables'] : null;
        } else {
            $query = $request->requestVar('query');
            $id = $request->requestVar('id');
            $variables = json_decode($request->requestVar('variables'), true);
        }

        if ($id) {
            if ($query) {
                throw new LogicException('Cannot pass a query when an ID has been specified.');
            }
            $query = $this->manager->getQueryFromPersistedID($id);
        }

        return [$query, $variables];
    }
protected function getRequestQueryVariables(HTTPRequest $request)
    {
        $contentType = $request->getHeader('content-type');
        $isJson = preg_match('#^application/json\b#', $contentType);
        if ($isJson) {
            $rawBody = $request->getBody();
            $data = json_decode($rawBody ?: '', true);
            $query = isset($data['query']) ? $data['query'] : null;
            $id = isset($data['id']) ? $data['id'] : null;
            $variables = isset($data['variables']) ? (array)$data['variables'] : null;
        } else {
            $query = $request->requestVar('query');
            $id = $request->requestVar('id');
            $variables = json_decode($request->requestVar('variables'), true);
        }

        if ($id) {
            if ($query) {
                throw new LogicException('Cannot pass a query when an ID has been specified.');
            }
            $query = $this->manager->getQueryFromPersistedID($id);
        }

        return [$query, $variables];
    }
protected function getRequestQueryVariables ( HTTPRequest $ request ) { $ contentType = $ request -> getHeader ( 'content-type' ) ; $ isJson = preg_match ( '#^application/json\b#' , $ contentType ) ; if ( $ isJson ) { $ rawBody = $ request -> getBody ( ) ; $ data = json_decode ( $ rawBody ? : '' , true ) ; $ query = isset ( $ data [ 'query' ] ) ? $ data [ 'query' ] : null ; $ id = isset ( $ data [ 'id' ] ) ? $ data [ 'id' ] : null ; $ variables = isset ( $ data [ 'variables' ] ) ? ( array ) $ data [ 'variables' ] : null ; } else { $ query = $ request -> requestVar ( 'query' ) ; $ id = $ request -> requestVar ( 'id' ) ; $ variables = json_decode ( $ request -> requestVar ( 'variables' ) , true ) ; } if ( $ id ) { if ( $ query ) { throw new LogicException ( 'Cannot pass a query when an ID has been specified.' ) ; } $ query = $ this -> manager -> getQueryFromPersistedID ( $ id ) ; } return [ $ query , $ variables ] ; }
Parse query and variables from the given request

@param HTTPRequest $request
@return array Array containing query and variables as a pair
@throws LogicException
Parse query and variables from the given request