Skip to content

Commit

Permalink
[ALLI-7634] EAC-CPF: Add sources to record details (vufind-org#2418)
Browse files Browse the repository at this point in the history
  • Loading branch information
rajaro authored Nov 9, 2022
1 parent 2d4a44d commit 9d500de
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions module/Finna/src/Finna/RecordDriver/SolrAuthEaccpf.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,36 @@ public function getOccupations()
return $result ?: $this->_getOccupations();
}

/**
* Return sources
*
* @return array
*/
public function getSources()
{
$result = [];
$record = $this->getXmlRecord();
if (isset($record->control->sources)) {
$languages = $this->mapLanguageCode($this->getLocale());
foreach ($record->control->sources->source as $source) {
if (isset($source->sourceEntry)) {
$title = '';
foreach ($source->sourceEntry as $entry) {
if (in_array($entry->attributes()->lang, $languages)) {
$title = (string)$entry;
}
}
$result[] = [
'title' => $title ? $title : (string)$source->sourceEntry,
'url' => (string)($source->attributes()->href ?? ''),
'subtitle' => ''
];
}
}
}
return $result;
}

/**
* Set preferred language for display strings.
*
Expand Down

0 comments on commit 9d500de

Please sign in to comment.