From 984569f0afef80c587e8490642bbb0ab5041408c Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Thu, 1 Feb 2018 15:23:45 -0500
Subject: [PATCH] Modernize record driver plugin manager service. - Eliminate
 static factory. - Use fully qualified class name as service name.

---
 module/VuFind/config/module.config.php           |  3 ++-
 .../Search/Factory/BrowZineBackendFactory.php    |  2 +-
 .../VuFind/Search/Factory/EITBackendFactory.php  |  2 +-
 .../VuFind/Search/Factory/EdsBackendFactory.php  |  2 +-
 .../Search/Factory/LibGuidesBackendFactory.php   |  2 +-
 .../Search/Factory/Pazpar2BackendFactory.php     |  2 +-
 .../Search/Factory/PrimoBackendFactory.php       |  2 +-
 .../Search/Factory/SolrAuthBackendFactory.php    |  2 +-
 .../Search/Factory/SolrDefaultBackendFactory.php |  2 +-
 .../Factory/SolrReservesBackendFactory.php       |  2 +-
 .../Search/Factory/SolrWebBackendFactory.php     |  2 +-
 .../Search/Factory/SummonBackendFactory.php      |  2 +-
 .../Search/Factory/WorldCatBackendFactory.php    |  2 +-
 module/VuFind/src/VuFind/Service/Factory.php     | 16 ++--------------
 module/VuFind/src/VuFindTest/Unit/TestCase.php   |  4 ++--
 15 files changed, 18 insertions(+), 29 deletions(-)

diff --git a/module/VuFind/config/module.config.php b/module/VuFind/config/module.config.php
index 5a95f0c0fb1..5789c763021 100644
--- a/module/VuFind/config/module.config.php
+++ b/module/VuFind/config/module.config.php
@@ -321,7 +321,7 @@ $config = [
             'VuFind\Recaptcha' => 'VuFind\Service\Factory::getRecaptcha',
             'VuFind\Recommend\PluginManager' => 'VuFind\ServiceManager\AbstractPluginManagerFactory',
             'VuFind\RecordCache' => 'VuFind\Service\Factory::getRecordCache',
-            'VuFind\RecordDriverPluginManager' => 'VuFind\Service\Factory::getRecordDriverPluginManager',
+            'VuFind\RecordDriver\PluginManager' => 'VuFind\ServiceManager\AbstractPluginManagerFactory',
             'VuFind\RecordLoader' => 'VuFind\Service\Factory::getRecordLoader',
             'VuFind\RecordRouter' => 'VuFind\Service\Factory::getRecordRouter',
             'VuFind\RecordTabPluginManager' => 'VuFind\Service\Factory::getRecordTabPluginManager',
@@ -388,6 +388,7 @@ $config = [
             'VuFind\ILSDriverPluginManager' => 'VuFind\ILS\Driver\PluginManager',
             'VuFind\IpAddressUtils' => 'VuFind\Net\IpAddressUtils',
             'VuFind\RecommendPluginManager' => 'VuFind\Recommend\PluginManager',
+            'VuFind\RecordDriverPluginManager' => 'VuFind\RecordDriver\PluginManager',
         ],
     ],
     'translator' => [],
diff --git a/module/VuFind/src/VuFind/Search/Factory/BrowZineBackendFactory.php b/module/VuFind/src/VuFind/Search/Factory/BrowZineBackendFactory.php
index 2ed515288dc..99a405a0eba 100644
--- a/module/VuFind/src/VuFind/Search/Factory/BrowZineBackendFactory.php
+++ b/module/VuFind/src/VuFind/Search/Factory/BrowZineBackendFactory.php
@@ -158,7 +158,7 @@ class BrowZineBackendFactory implements FactoryInterface
      */
     protected function createRecordCollectionFactory()
     {
-        $manager = $this->serviceLocator->get('VuFind\RecordDriverPluginManager');
+        $manager = $this->serviceLocator->get('VuFind\RecordDriver\PluginManager');
         $callback = function ($data) use ($manager) {
             $driver = $manager->get('BrowZine');
             $driver->setRawData($data);
diff --git a/module/VuFind/src/VuFind/Search/Factory/EITBackendFactory.php b/module/VuFind/src/VuFind/Search/Factory/EITBackendFactory.php
index 2a4b82eddf2..f31ee096246 100644
--- a/module/VuFind/src/VuFind/Search/Factory/EITBackendFactory.php
+++ b/module/VuFind/src/VuFind/Search/Factory/EITBackendFactory.php
@@ -149,7 +149,7 @@ class EITBackendFactory implements FactoryInterface
      */
     protected function createRecordCollectionFactory()
     {
-        $manager = $this->serviceLocator->get('VuFind\RecordDriverPluginManager');
+        $manager = $this->serviceLocator->get('VuFind\RecordDriver\PluginManager');
         $callback = function ($data) use ($manager) {
             $driver = $manager->get('EIT');
             $driver->setRawData($data);
diff --git a/module/VuFind/src/VuFind/Search/Factory/EdsBackendFactory.php b/module/VuFind/src/VuFind/Search/Factory/EdsBackendFactory.php
index b4010f514cb..a8ada0c7e8b 100644
--- a/module/VuFind/src/VuFind/Search/Factory/EdsBackendFactory.php
+++ b/module/VuFind/src/VuFind/Search/Factory/EdsBackendFactory.php
@@ -163,7 +163,7 @@ class EdsBackendFactory implements FactoryInterface
      */
     protected function createRecordCollectionFactory()
     {
-        $manager = $this->serviceLocator->get('VuFind\RecordDriverPluginManager');
+        $manager = $this->serviceLocator->get('VuFind\RecordDriver\PluginManager');
         $callback = function ($data) use ($manager) {
             $driver = $manager->get('EDS');
             $driver->setRawData($data);
diff --git a/module/VuFind/src/VuFind/Search/Factory/LibGuidesBackendFactory.php b/module/VuFind/src/VuFind/Search/Factory/LibGuidesBackendFactory.php
index 36cc2d39060..593b76ce39b 100644
--- a/module/VuFind/src/VuFind/Search/Factory/LibGuidesBackendFactory.php
+++ b/module/VuFind/src/VuFind/Search/Factory/LibGuidesBackendFactory.php
@@ -156,7 +156,7 @@ class LibGuidesBackendFactory implements FactoryInterface
      */
     protected function createRecordCollectionFactory()
     {
-        $manager = $this->serviceLocator->get('VuFind\RecordDriverPluginManager');
+        $manager = $this->serviceLocator->get('VuFind\RecordDriver\PluginManager');
         $callback = function ($data) use ($manager) {
             $driver = $manager->get('LibGuides');
             $driver->setRawData($data);
diff --git a/module/VuFind/src/VuFind/Search/Factory/Pazpar2BackendFactory.php b/module/VuFind/src/VuFind/Search/Factory/Pazpar2BackendFactory.php
index 7aa9a572402..af53ca5bada 100644
--- a/module/VuFind/src/VuFind/Search/Factory/Pazpar2BackendFactory.php
+++ b/module/VuFind/src/VuFind/Search/Factory/Pazpar2BackendFactory.php
@@ -148,7 +148,7 @@ class Pazpar2BackendFactory implements FactoryInterface
      */
     protected function createRecordCollectionFactory()
     {
-        $manager = $this->serviceLocator->get('VuFind\RecordDriverPluginManager');
+        $manager = $this->serviceLocator->get('VuFind\RecordDriver\PluginManager');
         $callback = function ($data) use ($manager) {
             $driver = $manager->get('Pazpar2');
             $driver->setRawData($data);
diff --git a/module/VuFind/src/VuFind/Search/Factory/PrimoBackendFactory.php b/module/VuFind/src/VuFind/Search/Factory/PrimoBackendFactory.php
index 980cbbb525c..2722a69144c 100644
--- a/module/VuFind/src/VuFind/Search/Factory/PrimoBackendFactory.php
+++ b/module/VuFind/src/VuFind/Search/Factory/PrimoBackendFactory.php
@@ -177,7 +177,7 @@ class PrimoBackendFactory implements FactoryInterface
      */
     protected function createRecordCollectionFactory()
     {
-        $manager = $this->serviceLocator->get('VuFind\RecordDriverPluginManager');
+        $manager = $this->serviceLocator->get('VuFind\RecordDriver\PluginManager');
         $callback = function ($data) use ($manager) {
             $driver = $manager->get('Primo');
             $driver->setRawData($data);
diff --git a/module/VuFind/src/VuFind/Search/Factory/SolrAuthBackendFactory.php b/module/VuFind/src/VuFind/Search/Factory/SolrAuthBackendFactory.php
index 108c4458d41..4cd87c37074 100644
--- a/module/VuFind/src/VuFind/Search/Factory/SolrAuthBackendFactory.php
+++ b/module/VuFind/src/VuFind/Search/Factory/SolrAuthBackendFactory.php
@@ -64,7 +64,7 @@ class SolrAuthBackendFactory extends AbstractSolrBackendFactory
     protected function createBackend(Connector $connector)
     {
         $backend = parent::createBackend($connector);
-        $manager = $this->serviceLocator->get('VuFind\RecordDriverPluginManager');
+        $manager = $this->serviceLocator->get('VuFind\RecordDriver\PluginManager');
         $callback = function ($data) use ($manager) {
             $driver = $manager->get('SolrAuth');
             $driver->setRawData($data);
diff --git a/module/VuFind/src/VuFind/Search/Factory/SolrDefaultBackendFactory.php b/module/VuFind/src/VuFind/Search/Factory/SolrDefaultBackendFactory.php
index b49adcdc707..0ce8c1721f5 100644
--- a/module/VuFind/src/VuFind/Search/Factory/SolrDefaultBackendFactory.php
+++ b/module/VuFind/src/VuFind/Search/Factory/SolrDefaultBackendFactory.php
@@ -76,7 +76,7 @@ class SolrDefaultBackendFactory extends AbstractSolrBackendFactory
     protected function createBackend(Connector $connector)
     {
         $backend = parent::createBackend($connector);
-        $manager = $this->serviceLocator->get('VuFind\RecordDriverPluginManager');
+        $manager = $this->serviceLocator->get('VuFind\RecordDriver\PluginManager');
         $factory = new RecordCollectionFactory([$manager, 'getSolrRecord']);
         $backend->setRecordCollectionFactory($factory);
         return $backend;
diff --git a/module/VuFind/src/VuFind/Search/Factory/SolrReservesBackendFactory.php b/module/VuFind/src/VuFind/Search/Factory/SolrReservesBackendFactory.php
index 79b855622ab..393c0539b7e 100644
--- a/module/VuFind/src/VuFind/Search/Factory/SolrReservesBackendFactory.php
+++ b/module/VuFind/src/VuFind/Search/Factory/SolrReservesBackendFactory.php
@@ -64,7 +64,7 @@ class SolrReservesBackendFactory extends AbstractSolrBackendFactory
     protected function createBackend(Connector $connector)
     {
         $backend = parent::createBackend($connector);
-        $manager = $this->serviceLocator->get('VuFind\RecordDriverPluginManager');
+        $manager = $this->serviceLocator->get('VuFind\RecordDriver\PluginManager');
         $callback = function ($data) use ($manager) {
             $driver = $manager->get('SolrReserves');
             $driver->setRawData($data);
diff --git a/module/VuFind/src/VuFind/Search/Factory/SolrWebBackendFactory.php b/module/VuFind/src/VuFind/Search/Factory/SolrWebBackendFactory.php
index 8d7b4b91456..030c8d816c3 100644
--- a/module/VuFind/src/VuFind/Search/Factory/SolrWebBackendFactory.php
+++ b/module/VuFind/src/VuFind/Search/Factory/SolrWebBackendFactory.php
@@ -89,7 +89,7 @@ class SolrWebBackendFactory extends AbstractSolrBackendFactory
     protected function createBackend(Connector $connector)
     {
         $backend = parent::createBackend($connector);
-        $manager = $this->serviceLocator->get('VuFind\RecordDriverPluginManager');
+        $manager = $this->serviceLocator->get('VuFind\RecordDriver\PluginManager');
         $callback = function ($data) use ($manager) {
             $driver = $manager->get('SolrWeb');
             $driver->setRawData($data);
diff --git a/module/VuFind/src/VuFind/Search/Factory/SummonBackendFactory.php b/module/VuFind/src/VuFind/Search/Factory/SummonBackendFactory.php
index 71cab74fc00..2464eb72997 100644
--- a/module/VuFind/src/VuFind/Search/Factory/SummonBackendFactory.php
+++ b/module/VuFind/src/VuFind/Search/Factory/SummonBackendFactory.php
@@ -177,7 +177,7 @@ class SummonBackendFactory implements FactoryInterface
      */
     protected function createRecordCollectionFactory()
     {
-        $manager = $this->serviceLocator->get('VuFind\RecordDriverPluginManager');
+        $manager = $this->serviceLocator->get('VuFind\RecordDriver\PluginManager');
         $stripSnippets = !isset($this->summonConfig->General->snippets)
             || !$this->summonConfig->General->snippets;
         $callback = function ($data) use ($manager, $stripSnippets) {
diff --git a/module/VuFind/src/VuFind/Search/Factory/WorldCatBackendFactory.php b/module/VuFind/src/VuFind/Search/Factory/WorldCatBackendFactory.php
index 384ad1c62d5..f62b6d153ca 100644
--- a/module/VuFind/src/VuFind/Search/Factory/WorldCatBackendFactory.php
+++ b/module/VuFind/src/VuFind/Search/Factory/WorldCatBackendFactory.php
@@ -156,7 +156,7 @@ class WorldCatBackendFactory implements FactoryInterface
      */
     protected function createRecordCollectionFactory()
     {
-        $manager = $this->serviceLocator->get('VuFind\RecordDriverPluginManager');
+        $manager = $this->serviceLocator->get('VuFind\RecordDriver\PluginManager');
         $callback = function ($data) use ($manager) {
             $driver = $manager->get('WorldCat');
             $driver->setRawData($data);
diff --git a/module/VuFind/src/VuFind/Service/Factory.php b/module/VuFind/src/VuFind/Service/Factory.php
index 59a2ad1ba6d..1afc598bf4d 100644
--- a/module/VuFind/src/VuFind/Service/Factory.php
+++ b/module/VuFind/src/VuFind/Service/Factory.php
@@ -236,24 +236,12 @@ class Factory
     public static function getRecordCache(ServiceManager $sm)
     {
         return new \VuFind\Record\Cache(
-            $sm->get('VuFind\RecordDriverPluginManager'),
+            $sm->get('VuFind\RecordDriver\PluginManager'),
             $sm->get('VuFind\Config\PluginManager')->get('RecordCache'),
             $sm->get('VuFind\Db\Table\PluginManager')->get('Record')
         );
     }
 
-    /**
-     * Construct the RecordDriver Plugin Manager.
-     *
-     * @param ServiceManager $sm Service manager.
-     *
-     * @return \VuFind\RecordDriver\PluginManager
-     */
-    public static function getRecordDriverPluginManager(ServiceManager $sm)
-    {
-        return static::getGenericPluginManager($sm, 'RecordDriver');
-    }
-
     /**
      * Construct the record loader.
      *
@@ -265,7 +253,7 @@ class Factory
     {
         return new \VuFind\Record\Loader(
             $sm->get('VuFind\Search'),
-            $sm->get('VuFind\RecordDriverPluginManager'),
+            $sm->get('VuFind\RecordDriver\PluginManager'),
             $sm->get('VuFind\RecordCache')
         );
     }
diff --git a/module/VuFind/src/VuFindTest/Unit/TestCase.php b/module/VuFind/src/VuFindTest/Unit/TestCase.php
index 92a44df44fe..508eca3a2bd 100644
--- a/module/VuFind/src/VuFindTest/Unit/TestCase.php
+++ b/module/VuFind/src/VuFindTest/Unit/TestCase.php
@@ -179,7 +179,7 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase
                 ]
             );
             $this->serviceManager->setService(
-                'VuFind\RecordDriverPluginManager', $recordDriverFactory
+                'VuFind\RecordDriver\PluginManager', $recordDriverFactory
             );
             $this->serviceManager->setService(
                 'VuFind\SearchSpecsReader', new \VuFind\Config\SearchSpecsReader()
@@ -202,7 +202,7 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase
             $this->serviceManager->setService(
                 'VuFind\RecordLoader', new \VuFind\Record\Loader(
                     $this->serviceManager->get('VuFind\Search'),
-                    $this->serviceManager->get('VuFind\RecordDriverPluginManager')
+                    $this->serviceManager->get('VuFind\RecordDriver\PluginManager')
                 )
             );
             $this->serviceManager->setService('Config', []);
-- 
GitLab