From cee03b53eb89e10ef112649772910427637b82bb Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Fri, 14 Dec 2012 12:57:28 -0500 Subject: [PATCH] Added convenience method to record driver plugin manager to easily build Solr objects. --- .../src/VuFind/RecordDriver/PluginManager.php | 18 ++++++++++++++++++ .../VuFind/src/VuFind/Search/Solr/Results.php | 13 +++---------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/module/VuFind/src/VuFind/RecordDriver/PluginManager.php b/module/VuFind/src/VuFind/RecordDriver/PluginManager.php index 7c4f3cd7279..5dc071a5496 100644 --- a/module/VuFind/src/VuFind/RecordDriver/PluginManager.php +++ b/module/VuFind/src/VuFind/RecordDriver/PluginManager.php @@ -79,4 +79,22 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager { 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 diff --git a/module/VuFind/src/VuFind/Search/Solr/Results.php b/module/VuFind/src/VuFind/Search/Solr/Results.php index 29ba2a08d7b..d506706e74e 100644 --- a/module/VuFind/src/VuFind/Search/Solr/Results.php +++ b/module/VuFind/src/VuFind/Search/Solr/Results.php @@ -538,16 +538,9 @@ class Results extends BaseResults */ protected function initRecordDriver($data) { - $factory = $this->getServiceLocator() - ->get('VuFind\RecordDriverPluginManager'); - - $key = 'Solr' . ucwords($data['recordtype']); - $recordType = $factory->has($key) ? $key : 'SolrDefault'; - - // Build the object: - $driver = $factory->get($recordType); - $driver->setRawData($data); - return $driver; + return $this->getServiceLocator() + ->get('VuFind\RecordDriverPluginManager') + ->getSolrRecord($data); } /** -- GitLab