Skip to content

Commit

Permalink
QDC: Check for a namespaced ID in getID method.
Browse files Browse the repository at this point in the history
  • Loading branch information
EreMaijala committed Nov 10, 2023
1 parent aa0e6a8 commit 0b644b4
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/RecordManager/Base/Record/Qdc.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ class Qdc extends AbstractRecord
*/
protected $db;

/**
* Record namespace identifier
*
* @var string
*/
protected $recordNs = 'http://www.openarchives.org/OAI/2.0/oai_dc/';

/**
* Constructor
*
Expand Down Expand Up @@ -105,7 +112,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;
Expand All @@ -120,7 +127,11 @@ public function setData($source, $oaiID, $data)
*/
public function getID()
{
return trim((string)$this->doc->recordID[0]);
$id = (string)$this->doc->recordID[0];
if ('' === $id) {
$id = (string)$this->doc->children($this->recordNs)->recordID[0];
}
return trim($id);
}

/**
Expand Down

0 comments on commit 0b644b4

Please sign in to comment.