Skip to content

Commit

Permalink
EAD3: If addIdToHierarchyTitle setting is true and sequenceUnitIdLabe…
Browse files Browse the repository at this point in the history
…l not found, use first unitid
  • Loading branch information
mshroom committed May 23, 2024
1 parent 877cbff commit 9b444f3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/RecordManager/Base/Record/Ead3.php
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ protected function getUnitId()
protected function getHierarchyFields(array &$data): void
{
$data['hierarchytype'] = 'Default';
$sequenceUnitId = '';
$sequenceUnitId = $firstId = '';
if ($this->doc->{'add-data'}->archive) {
$archiveAttr = $this->doc->{'add-data'}->archive->attributes();
$data['hierarchy_top_id'] = (string)$archiveAttr->{'id'};
Expand All @@ -531,6 +531,7 @@ protected function getHierarchyFields(array &$data): void
$seqLabel = $this->getDriverParam('sequenceUnitIdLabel', 'sequence');
if ($seqLabel) {
foreach ($this->doc->did->unitid ?? [] as $unitId) {
$firstId = $firstId ?: $unitId;
if ($seqLabel === (string)$unitId->attributes()->label) {
$sequenceUnitId = (string)$unitId;
$data['hierarchy_sequence']
Expand All @@ -553,6 +554,7 @@ protected function getHierarchyFields(array &$data): void
$data['is_hierarchy_title'] = $data['hierarchy_top_title']
= (string)($this->doc->did->unittitle ?? '');
}
$sequenceUnitId = $sequenceUnitId ?: $firstId;
if (
$sequenceUnitId
&& $this->getDriverParam('addIdToHierarchyTitle', true)
Expand Down

0 comments on commit 9b444f3

Please sign in to comment.