diff --git a/src/RecordManager/Base/Splitter/Ead3.php b/src/RecordManager/Base/Splitter/Ead3.php index a30278cf..c96b9867 100644 --- a/src/RecordManager/Base/Splitter/Ead3.php +++ b/src/RecordManager/Base/Splitter/Ead3.php @@ -144,6 +144,62 @@ public function getNextRecord() $this->appendXMLFiltered($record, $child); } + $ancestorDid = $original->xpath('ancestor::*/did'); + + if ($ancestorDid) { + // Append any ancestor did's + foreach (array_reverse($ancestorDid) as $did) { + $this->appendXML($record, $did, $this->nonInheritedFields); + } + } + + if ($record->getName() !== 'archdesc') { + foreach ($this->doc->archdesc->bibliography ?? [] as $elem) { + $this->appendXML($record, $elem, $this->nonInheritedFields); + } + + foreach ($this->doc->archdesc->accessrestrict ?? [] as $elem) { + $this->appendXML($record, $elem, $this->nonInheritedFields); + } + } + + $this->addAdditionalData($record, $original); + + return ['metadata' => $record->asXML()]; + } + + /** + * Get archive title + * + * @return string + */ + protected function getArchiveTitle(): string + { + return (string)$this->doc->archdesc->did->unittitle; + } + + /** + * Get parent unit id for prepending to parent title + * + * @param \SimpleXMLElement $parentDid Parent did + * + * @return string + */ + protected function getParentUnitId(\SimpleXMLElement $parentDid): string + { + return (string)($parentDid->unitid ?? ''); + } + + /** + * Add and form additional data to record + * + * @param \SimpleXMLElement $record The record + * @param \SimpleXMLElement $original The original record + * + * @return void + */ + protected function addAdditionalData(&$record, &$original): void + { $addData = $record->addChild('add-data'); $unitId = ''; @@ -205,25 +261,6 @@ public function getNextRecord() $absolute->addAttribute('subtitle', $this->archiveSubTitle); } - $ancestorDid = $original->xpath('ancestor::*/did'); - - if ($ancestorDid) { - // Append any ancestor did's - foreach (array_reverse($ancestorDid) as $did) { - $this->appendXML($record, $did, $this->nonInheritedFields); - } - } - - if ($record->getName() !== 'archdesc') { - foreach ($this->doc->archdesc->bibliography ?? [] as $elem) { - $this->appendXML($record, $elem, $this->nonInheritedFields); - } - - foreach ($this->doc->archdesc->accessrestrict ?? [] as $elem) { - $this->appendXML($record, $elem, $this->nonInheritedFields); - } - } - $parentDid = $original->xpath('parent::*/did'); if ($parentDid) { $parentDid = $parentDid[0]; @@ -298,29 +335,5 @@ public function getNextRecord() $parent->addAttribute('level', 'archive'); } } - - return ['metadata' => $record->asXML()]; - } - - /** - * Get archive title - * - * @return string - */ - protected function getArchiveTitle(): string - { - return (string)$this->doc->archdesc->did->unittitle; - } - - /** - * Get parent unit id for prepending to parent title - * - * @param \SimpleXMLElement $parentDid Parent did - * - * @return string - */ - protected function getParentUnitId(\SimpleXMLElement $parentDid): string - { - return (string)($parentDid->unitid ?? ''); } }