From d12e04bd716ca9d5d1c34c5f1dc4a8c8dc719bb9 Mon Sep 17 00:00:00 2001 From: Ere Maijala Date: Fri, 10 Nov 2023 15:10:59 +0200 Subject: [PATCH] DC: Check for a namespaced ID in getID method. --- src/RecordManager/Base/Record/Dc.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/RecordManager/Base/Record/Dc.php b/src/RecordManager/Base/Record/Dc.php index f475142fa..d9cf04d97 100644 --- a/src/RecordManager/Base/Record/Dc.php +++ b/src/RecordManager/Base/Record/Dc.php @@ -73,6 +73,13 @@ class Dc extends AbstractRecord */ protected $db; + /** + * Record namespace identifier + * + * @var string + */ + protected $recordNs = 'http://www.openarchives.org/OAI/2.0/oai_dc/'; + /** * Constructor * @@ -112,7 +119,7 @@ public function setData($source, $oaiID, $data) if ( empty($this->doc->recordID) - && empty($this->doc->children('http://www.openarchives.org/OAI/2.0/oai_dc/')->recordID) + && empty($this->doc->children($this->recordNs)->recordID) ) { $parts = explode(':', $oaiID); $id = ('oai' === $parts[0] && !empty($parts[2])) ? $parts[2] : $oaiID; @@ -127,7 +134,11 @@ public function setData($source, $oaiID, $data) */ public function getID() { - return (string)$this->doc->recordID[0]; + $id = (string)$this->doc->recordID[0]; + if ('' === $id) { + $id = (string)$this->doc->children($this->recordNs)->recordID[0]; + } + return $id; } /**