diff --git a/app/PrimoRecord.php b/app/PrimoRecord.php index 9c3c3be..d427bfe 100644 --- a/app/PrimoRecord.php +++ b/app/PrimoRecord.php @@ -6,7 +6,7 @@ use BCLib\PrimoServices\QueryTerm; use Danmichaelo\QuiteSimpleXMLElement\QuiteSimpleXMLElement; -class PrimoRecord implements \JsonSerializable +class PrimoRecord extends PrimoResult implements \JsonSerializable { public $orderedMaterialList = ['e-books', 'print-books']; protected $brief; @@ -192,25 +192,16 @@ function extractGetIts($getits) return $out; } - public function primoLink() + public function link() { - if ($this->multiple_editions) { - - $queryTerm = new QueryTerm(); - $queryTerm->set('facet_frbrgroupid', QueryTerm::EXACT, $this->id); - - return 'http://' . $this->deeplinkProvider->view('UBO') - ->search($queryTerm, null, 'library_catalogue'); - - } else { - return 'http://' . $this->deeplinkProvider->view('UBO') - ->link($this->id); - } + return url('primo/records/' .$this->id); } - public function link() + public function primoLink() { - return url('primo/records/' .$this->id); + return 'http://' . $this->deeplinkProvider + ->view('UBO') + ->link($this->id); } public function groupLink() @@ -228,25 +219,6 @@ public function jsonSerialize() return toArray('full'); } - public function toArray($fullRepr=false) - { - $data = $this->brief; - $data['links'] = [ - 'self' => $this->link(), - ]; - if ($fullRepr) { - $data['links']['primo'] = $this->primoLink(); - $data['links']['group'] = $this->groupLink(); - $data['links']['cover'] = $this->coverLink(); - // $this->addLocations(); - } - - if ($fullRepr) { - $data = array_merge($data, $this->full); - } - return $data; - } - public function & getComponent(&$components, $id) { if (count($components) == 1) { @@ -413,4 +385,4 @@ private function extractArray(QuiteSimpleXMLElement $group, $xpath) }, $group->all($xpath)); } -} \ No newline at end of file +} diff --git a/app/PrimoRecordGroup.php b/app/PrimoRecordGroup.php index ace1b09..27890bc 100644 --- a/app/PrimoRecordGroup.php +++ b/app/PrimoRecordGroup.php @@ -6,7 +6,7 @@ use BCLib\PrimoServices\QueryTerm; use Danmichaelo\QuiteSimpleXMLElement\QuiteSimpleXMLElement; -class PrimoRecordGroup implements \JsonSerializable +class PrimoRecordGroup extends PrimoResult implements \JsonSerializable { protected $brief; protected $full; @@ -40,6 +40,16 @@ public function link() return url('primo/groups/' .$this->id); } + public function primoLink() + { + $queryTerm = new QueryTerm(); + $queryTerm->set('facet_frbrgroupid', QueryTerm::EXACT, $this->id); + + return 'http://' . $this->deeplinkProvider + ->view('UBO') + ->search($queryTerm, 'bibsys_ils', 'library_catalogue'); + } + public function process() { $record = $this->doc->first('./p:PrimoNMBib/p:record'); @@ -54,13 +64,6 @@ public function process() return $this; } - public function toArray($expanded=false) - { - $data = $this->brief; - $data['links']['self'] = $this->link(); - return $data; - } - public function jsonSerialize() { return $this->toArray(); @@ -73,4 +76,4 @@ private function extractArray(QuiteSimpleXMLElement $group, $xpath) }, $group->all($xpath)); } -} \ No newline at end of file +} diff --git a/app/PrimoResult.php b/app/PrimoResult.php new file mode 100644 index 0000000..6daf923 --- /dev/null +++ b/app/PrimoResult.php @@ -0,0 +1,33 @@ +brief; + $data['links'] = [ + 'self' => $this->link(), + ]; + if ($fullRepr) { + $data['links']['primo'] = $this->primoLink(); + if ($this instanceof PrimoRecord) { + $data['links']['group'] = $this->groupLink(); + $data['links']['cover'] = $this->coverLink(); + } + // $this->addLocations(); + } + + if ($fullRepr) { + $data = array_merge($data, $this->full); + } + return $data; + } + +}