Skip to content
Snippets Groups Projects
Commit 82a5eba4 authored by tubia's avatar tubia Committed by Demian Katz
Browse files

Added Solr id prefix setting to NoILS driver.

- This applies when NoILS is used in combo with MultiBackend.
parent 4c947f76
No related merge requests found
...@@ -14,6 +14,11 @@ useHoldings = none ...@@ -14,6 +14,11 @@ useHoldings = none
; marc = Use information in the Marc Record Mapped from [MarcStatus] ; marc = Use information in the Marc Record Mapped from [MarcStatus]
; custom = use the options in the [Status] section below ; custom = use the options in the [Status] section below
useStatus = none useStatus = none
;idPrefix - Optional - Prefix added to Solr record IDs managed by this instance of
; the NoILS driver; needed when using this driver in combination with the
; MultiBackend driver. When used, the value should usually match one of the keys
; in the [Drivers] section of MultiBackend.ini followed by a dot.
;idPrefix = "instance1."
[MarcHoldings] [MarcHoldings]
; Used if useHoldings is set to "marc" ; Used if useHoldings is set to "marc"
......
...@@ -91,6 +91,17 @@ class NoILS extends AbstractBase implements TranslatorAwareInterface ...@@ -91,6 +91,17 @@ class NoILS extends AbstractBase implements TranslatorAwareInterface
return isset($this->config[$function]) ? $this->config[$function] : false; return isset($this->config[$function]) ? $this->config[$function] : false;
} }
/**
* Get the ID prefix from the configuration, if set.
*
* @return string
*/
protected function getIdPrefix()
{
return isset($this->config['settings']['idPrefix'])
? $this->config['settings']['idPrefix'] : null;
}
/** /**
* Get a Solr record. * Get a Solr record.
* *
...@@ -100,7 +111,9 @@ class NoILS extends AbstractBase implements TranslatorAwareInterface ...@@ -100,7 +111,9 @@ class NoILS extends AbstractBase implements TranslatorAwareInterface
*/ */
protected function getSolrRecord($id) protected function getSolrRecord($id)
{ {
return $this->recordLoader->load($id); // Add idPrefix condition
$idPrefix = $this->getIdPrefix();
return $this->recordLoader->load(strlen($idPrefix) ? $idPrefix . $id : $id);
} }
/** /**
...@@ -246,6 +259,13 @@ class NoILS extends AbstractBase implements TranslatorAwareInterface ...@@ -246,6 +259,13 @@ class NoILS extends AbstractBase implements TranslatorAwareInterface
$result = $recordDriver->tryMethod( $result = $recordDriver->tryMethod(
'getFormattedMarcDetails', [$field, $marcStatus] 'getFormattedMarcDetails', [$field, $marcStatus]
); );
// If the details coming back from the record driver include the
// ID prefix, strip it off!
$idPrefix = $this->getIdPrefix();
if (isset($result[0]['id']) && strlen($idPrefix)
&& $idPrefix === substr($result[0]['id'], 0, strlen($idPrefix))) {
$result[0]['id'] = substr($result[0]['id'], strlen($idPrefix));
}
return empty($result) ? [] : $result; return empty($result) ? [] : $result;
} }
return []; return [];
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment