/**
  * Append fields from dedup record to the selected local record
  *
  * @param array  $localRecordData Local record data
  * @param array  $dedupRecordData Dedup record data
  * @param string $recordSources   List of active record sources, empty if all
  * @param array  $sourcePriority  Array of source priorities keyed by source id
  *
  * @return array Local record data
  */
 protected function appendDedupRecordFields($localRecordData, $dedupRecordData, $recordSources, $sourcePriority)
 {
     $localRecordData = parent::appendDedupRecordFields($localRecordData, $dedupRecordData, $recordSources, $sourcePriority);
     if (isset($dedupRecordData['online_urls_str_mv'])) {
         $localRecordData['online_urls_str_mv'] = [];
         foreach ($dedupRecordData['online_urls_str_mv'] as $onlineURL) {
             $onlineURLArray = json_decode($onlineURL, true);
             if (!$recordSources || isset($sourcePriority[$onlineURLArray['source']])) {
                 $localRecordData['online_urls_str_mv'][] = $onlineURL;
             }
         }
     }
     return $localRecordData;
 }
 /**
  * Fetch local records for all the found dedup records
  *
  * @param EventInterface $event Event
  *
  * @return void
  */
 protected function fetchLocalRecords($event)
 {
     parent::fetchLocalRecords($event);
     if (!isset($_ENV['VUFIND_API_CALL']) || !$_ENV['VUFIND_API_CALL']) {
         return;
     }
     $config = $this->serviceLocator->get('VuFind\\Config');
     $searchConfig = $config->get($this->searchConfig);
     if (!isset($searchConfig->Records->apiExcludedSources)) {
         return;
     }
     $excluded = explode(',', $searchConfig->Records->apiExcludedSources);
     $result = $event->getTarget();
     foreach ($result->getRecords() as $record) {
         $fields = $record->getRawData();
         if (!isset($fields['dedup_data'])) {
             continue;
         }
         foreach ($excluded as $item) {
             unset($fields['dedup_data'][$item]);
         }
         $record->setRawData($fields);
     }
 }