protected function processQuery(Query $queryObj, $expanded, $fullRepr, $options) { $url = str_replace('json=true&', '', $this->primo->url('brief', $queryObj)); if (!count($queryObj->getTerms())) { throw new PrimoException('No query given', 0, null, $url); } $client = new HttpClient(); $request = $client->get($url); $body = $request->send()->getBody(); if ($options->get('raw') == 'true') { return strval($body); } $root = new QuiteSimpleXMLElement(strval($body)); $root->registerXPathNamespace('s', 'http://www.exlibrisgroup.com/xsd/jaguar/search'); $root->registerXPathNamespace('p', 'http://www.exlibrisgroup.com/xsd/primo/primo_nm_bib'); $error = $root->first('/s:SEGMENTS/s:JAGROOT/s:RESULT/s:ERROR'); if ($error) { throw new PrimoException($error->attr('MESSAGE'), 0, null, $url); } $deeplinkProvider = $this->primo->createDeepLink(); $out = []; foreach ($root->xpath('//s:DOC') as $doc) { $out[] = PrimoRecord::make($doc, $deeplinkProvider, $expanded, $this->getRecordOptions($options))->toArray($fullRepr); } $facets = []; $vocab = $options->get('vocabulary'); if (isset($this->indices[$vocab])) { $facets[$vocab] = $this->parseFacet($root, 'local' . $this->indices[$vocab]); } $docset = $root->first('//s:DOCSET'); $hits = intval($docset->attr('TOTALHITS')); $first = intval($docset->attr('FIRSTHIT')); $next = intval($docset->attr('LASTHIT')) + 1; if ($next > $hits) { $next = null; } return ['source' => $url, 'first' => $first, 'next' => $next, 'total_results' => $hits, 'results' => $out, 'facets' => $facets]; }