The Gitlab instance will be restarted on Monday April 28th at 2AM. There will be a short interruption of service.

Skip to content
Snippets Groups Projects
Commit cee03b53 authored by Demian Katz's avatar Demian Katz
Browse files

Added convenience method to record driver plugin manager to easily build Solr objects.

parent 5d28408d
No related merge requests found
...@@ -79,4 +79,22 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager ...@@ -79,4 +79,22 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager
{ {
return 'VuFind\RecordDriver\AbstractBase'; return 'VuFind\RecordDriver\AbstractBase';
} }
/**
* Convenience method to retrieve a populated Solr record driver.
*
* @param array $data Raw Solr data
*
* @return AbstractBase
*/
public function getSolrRecord($data)
{
$key = 'Solr' . ucwords($data['recordtype']);
$recordType = $this->has($key) ? $key : 'SolrDefault';
// Build the object:
$driver = $this->get($recordType);
$driver->setRawData($data);
return $driver;
}
} }
\ No newline at end of file
...@@ -538,16 +538,9 @@ class Results extends BaseResults ...@@ -538,16 +538,9 @@ class Results extends BaseResults
*/ */
protected function initRecordDriver($data) protected function initRecordDriver($data)
{ {
$factory = $this->getServiceLocator() return $this->getServiceLocator()
->get('VuFind\RecordDriverPluginManager'); ->get('VuFind\RecordDriverPluginManager')
->getSolrRecord($data);
$key = 'Solr' . ucwords($data['recordtype']);
$recordType = $factory->has($key) ? $key : 'SolrDefault';
// Build the object:
$driver = $factory->get($recordType);
$driver->setRawData($data);
return $driver;
} }
/** /**
......
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