static function make(QuiteSimpleXMLElement $doc, DeepLink $deeplinkProvider, $expanded = false, $options) { $is_group = $doc->text('./p:PrimoNMBib/p:record/p:facets/p:frbrtype') != '6' && $doc->text('./p:PrimoNMBib/p:record/p:display/p:version', '1') != '1'; if ($is_group && !$expanded) { $item = new PrimoRecordGroup($doc, $deeplinkProvider, $options); } else { $item = new PrimoRecord($doc, $deeplinkProvider, $options); } return $item->process(); }
public function loadPrimoRecord($filename) { $xml = file_get_contents(__DIR__ . '/data/' . $filename); $root = new QuiteSimpleXMLElement($xml); $root->registerXPathNamespace('s', 'http://www.exlibrisgroup.com/xsd/jaguar/search'); $root->registerXPathNamespace('p', 'http://www.exlibrisgroup.com/xsd/primo/primo_nm_bib'); $doc = $root->first('//s:DOC'); $dl = new DeepLink('', ''); return PrimoRecord::make($doc, $dl, false, [])->toArray(true); }
public function getRecord($docId, $options) { $institution = $options->get('institution', config('app.primo.institution')); $scope = $options->get('scope', config('app.primo.default_scope')); $queryObj = new Query($institution); $queryObj->local($scope); $queryObj->onCampus(true); $url = str_replace('json=true&', '', $this->primo->url('full', $queryObj)); $url = str_replace('&indx=1&bulkSize=10', '', $url); $url .= '&docId=' . $docId . '&getDelivery=true'; $client = new HttpClient(); $request = $client->get($url); $body = $request->send()->getBody(); if ($options->get('raw') == 'true') { return $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'); $deeplinkProvider = $this->primo->createDeepLink(); $error = $root->first('/s:SEGMENTS/s:JAGROOT/s:RESULT/s:ERROR'); if ($error) { throw new PrimoException($error->attr('MESSAGE'), 0, null, $url); } $doc = $root->first('//s:DOC'); if (!$doc) { throw new PrimoException('Invalid response from Primo', 0, null, $url); } $out = PrimoRecord::make($doc, $deeplinkProvider, true, $this->getRecordOptions($options))->toArray('full'); return ['source' => $url, 'error' => null, 'result' => $out]; }