Skip to content

Commit 1cc5585

Browse files
authored
[FINNA-3834] LIDO: Improve handling of type and pref attributes (#183)
1 parent eadf7db commit 1cc5585

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/RecordManager/Base/Record/Lido.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,13 @@ class Lido extends AbstractRecord
115115
*/
116116
protected $subjectConceptIDTypes = ['uri', 'url'];
117117

118+
/**
119+
* Title types for preferred titles.
120+
*
121+
* @var array
122+
*/
123+
protected $preferredTitleTypes = ['preferred'];
124+
118125
/**
119126
* Repository location types to be included.
120127
*
@@ -486,13 +493,13 @@ protected function getTitles()
486493
if (!($title = trim((string)$appellationValue))) {
487494
continue;
488495
}
489-
$preference = (string)$appellationValue['pref'] ?: 'preferred';
496+
$preference = mb_strtolower((string)($appellationValue->attributes()->pref ?? 'preferred'), 'UTF-8');
490497
$titleLang = $this->getInheritedXmlAttribute(
491498
$appellationValue,
492499
'lang',
493500
$defaultLanguage
494501
);
495-
if ('preferred' === $preference) {
502+
if (in_array($preference, $this->preferredTitleTypes)) {
496503
$preferredParts[$titleLang][] = $title;
497504
} else {
498505
$alternateParts[$titleLang][] = $title;
@@ -1341,7 +1348,7 @@ protected function getRepositoryLocations(): array
13411348
$this->doc->lido->descriptiveMetadata->objectIdentificationWrap->repositoryWrap->repositorySet
13421349
?? [] as $set
13431350
) {
1344-
$type = (string)($set->attributes()->type ?? '');
1351+
$type = mb_strtolower((string)($set->attributes()->type ?? ''), 'UTF-8');
13451352
if ($this->repositoryLocationTypes && !in_array($type, $this->repositoryLocationTypes)) {
13461353
continue;
13471354
}

0 commit comments

Comments
 (0)