Skip to content

Commit

Permalink
LIDO: Display identifier type preferably from label attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
mshroom committed Jan 7, 2025
1 parent 0ada486 commit 11e8975
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions module/Finna/src/Finna/RecordDriver/SolrLido.php
Original file line number Diff line number Diff line change
Expand Up @@ -2388,8 +2388,8 @@ protected function getDataSourceConfigurationValue($confParam)
* Get identifiers by type
*
* @param bool $includeType Whether to include identifier type in parenthesis
* @param array $include Type attributes to include
* @param array $exclude Type attributes to exclude
* @param array $include Type and label attributes to include
* @param array $exclude Type and label attributes to exclude
*
* @return array
*/
Expand All @@ -2405,16 +2405,18 @@ protected function getIdentifiersByType(
->repositorySet ?? [] as $repository
) {
foreach ($repository->workID ?? [] as $node) {
$type = $node->attributes()->type ?? '';
$label = trim((string)($node->attributes()->label ?? ''));
$type = trim((string)($node->attributes()->type ?? ''));
$typesLC = [mb_strtolower($label, 'UTF-8'), mb_strtolower($type, 'UTF-8')];
if (
($include && !in_array($type, $include))
|| ($exclude && in_array($type, $exclude))
($include && !array_intersect($typesLC, $include))
|| ($exclude && array_intersect($typesLC, $exclude))
) {
continue;
}
if ($identifier = trim((string)$node ?? '')) {
if ($type && $includeType) {
$identifier .= " ($type)";
if (($label || $type) && $includeType) {
$identifier .= ' (' . ($label ?: $type) . ')';
}
$results[] = $identifier;
}
Expand Down

0 comments on commit 11e8975

Please sign in to comment.