From 5c32852ad3ea709bc7430b51cdf8a5ad25c4f521 Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Fri, 24 Oct 2014 08:48:11 -0400
Subject: [PATCH] Factory cleanup. - Fixed some bad parameters - Made some code
 more compact - Used an invokable where a factory was unnecessary

---
 module/VuFind/config/module.config.php        |  4 ++-
 .../src/VuFind/RecordDriver/Factory.php       | 32 ++++++-------------
 2 files changed, 12 insertions(+), 24 deletions(-)

diff --git a/module/VuFind/config/module.config.php b/module/VuFind/config/module.config.php
index 4db1176abc7..25fd11a7258 100644
--- a/module/VuFind/config/module.config.php
+++ b/module/VuFind/config/module.config.php
@@ -431,7 +431,6 @@ $config = array(
                 'factories' => array(
                     'eds' => 'VuFind\RecordDriver\Factory::getEDS',
                     'eit' => 'VuFind\RecordDriver\Factory::getEIT',
-                    'libguides' => 'VuFind\RecordDriver\Factory::getLibGuides',
                     'missing' => 'VuFind\RecordDriver\Factory::getMissing',
                     'pazpar2' => 'VuFind\RecordDriver\Factory::getPazpar2',
                     'primo' => 'VuFind\RecordDriver\Factory::getPrimo',
@@ -443,6 +442,9 @@ $config = array(
                     'summon' => 'VuFind\RecordDriver\Factory::getSummon',
                     'worldcat' => 'VuFind\RecordDriver\Factory::getWorldCat',
                 ),
+                'invokables' => array(
+                    'libguides' => 'VuFind\RecordDriver\LibGuides',
+                ),
             ),
             'recordtab' => array(
                 'abstract_factories' => array('VuFind\RecordTab\PluginFactory'),
diff --git a/module/VuFind/src/VuFind/RecordDriver/Factory.php b/module/VuFind/src/VuFind/RecordDriver/Factory.php
index cb8900e653a..f16ffe51c4a 100644
--- a/module/VuFind/src/VuFind/RecordDriver/Factory.php
+++ b/module/VuFind/src/VuFind/RecordDriver/Factory.php
@@ -51,8 +51,7 @@ class Factory
     {
         $eds = $sm->getServiceLocator()->get('VuFind\Config')->get('EDS');
         return new EDS(
-            $sm->getServiceLocator()->get('VuFind\Config')->get('config'),
-            $eds, $eds
+            $sm->getServiceLocator()->get('VuFind\Config')->get('config'), $eds, $eds
         );
     }
 
@@ -65,22 +64,12 @@ class Factory
      */
     public static function getEIT(ServiceManager $sm)
     {
+        $eit = $sm->getServiceLocator()->get('VuFind\Config')->get('EIT');
         return new EIT(
-            $sm->getServiceLocator()->get('VuFind\Config')->get('config'),
-            $sm->getServiceLocator()->get('VuFind\Config')->get('EIT')
+            $sm->getServiceLocator()->get('VuFind\Config')->get('config'), $eit, $eit
         );
     }
 
-    /**
-     * Factory for LibGuides record driver.
-     *
-     * @return LibGuides
-     */
-    public static function getLibGuides()
-    {
-        return new LibGuides();
-    }
-
     /**
      * Factory for Missing record driver.
      *
@@ -104,10 +93,9 @@ class Factory
      */
     public static function getPazpar2(ServiceManager $sm)
     {
+        $pp2 = $sm->getServiceLocator()->get('VuFind\Config')->get('Pazpar2');
         return new Pazpar2(
-            $sm->getServiceLocator()->get('VuFind\Config')->get('config'),
-            null,
-            $sm->getServiceLocator()->get('VuFind\Config')->get('searches')
+            $sm->getServiceLocator()->get('VuFind\Config')->get('config'), $pp2, $pp2
         );
     }
 
@@ -207,11 +195,9 @@ class Factory
      */
     public static function getSolrWeb(ServiceManager $sm)
     {
+        $web = $sm->getServiceLocator()->get('VuFind\Config')->get('website');
         return new SolrWeb(
-            $sm->getServiceLocator()->get('VuFind\Config')->get('config'),
-            null,
-            $sm->getServiceLocator()->get('VuFind\Config')->get('website'),
-            $sm->getServiceLocator()->get('VuFind\Config')->get('website')
+            $sm->getServiceLocator()->get('VuFind\Config')->get('config'), $web, $web
         );
     }
 
@@ -244,9 +230,9 @@ class Factory
      */
     public static function getWorldCat(ServiceManager $sm)
     {
+        $wc = $sm->getServiceLocator()->get('VuFind\Config')->get('WorldCat');
         return new WorldCat(
-            $sm->getServiceLocator()->get('VuFind\Config')->get('config'),
-            $sm->getServiceLocator()->get('VuFind\Config')->get('WorldCat')
+            $sm->getServiceLocator()->get('VuFind\Config')->get('config'), $wc, $wc
         );
     }
 }
\ No newline at end of file
-- 
GitLab