diff --git a/config/vufind/NoILS.ini b/config/vufind/NoILS.ini index f76ae81a88d32ec6db4962fd129bf05941224ee2..25a793100b8da1cc295b7e26ce1833d6dcd5de07 100644 --- a/config/vufind/NoILS.ini +++ b/config/vufind/NoILS.ini @@ -14,6 +14,11 @@ useHoldings = none ; marc = Use information in the Marc Record Mapped from [MarcStatus] ; custom = use the options in the [Status] section below 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] ; Used if useHoldings is set to "marc" diff --git a/module/VuFind/src/VuFind/ILS/Driver/NoILS.php b/module/VuFind/src/VuFind/ILS/Driver/NoILS.php index c72dc3923d95f10de48830dd8880cfe186319483..b34b62222ac540075f4a3aba7f532955c3b8bb6e 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/NoILS.php +++ b/module/VuFind/src/VuFind/ILS/Driver/NoILS.php @@ -91,6 +91,17 @@ class NoILS extends AbstractBase implements TranslatorAwareInterface 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. * @@ -100,7 +111,9 @@ class NoILS extends AbstractBase implements TranslatorAwareInterface */ 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 $result = $recordDriver->tryMethod( '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 [];