From d054e174ad646eda78d90df2d9fc06e13f534cd0 Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Tue, 30 Jan 2018 13:31:39 -0500
Subject: [PATCH] Modernize auth plugin manager server. - Eliminate static
 factory. - Use fully qualified class name as service name.

---
 module/VuFind/config/module.config.php         |  3 ++-
 module/VuFind/src/VuFind/Auth/Factory.php      |  6 +++---
 module/VuFind/src/VuFind/Service/Factory.php   | 12 ------------
 module/VuFind/src/VuFindTest/Unit/TestCase.php |  6 +++---
 4 files changed, 8 insertions(+), 19 deletions(-)

diff --git a/module/VuFind/config/module.config.php b/module/VuFind/config/module.config.php
index 020b105ae4a..9d5d23aecd6 100644
--- a/module/VuFind/config/module.config.php
+++ b/module/VuFind/config/module.config.php
@@ -281,7 +281,7 @@ $config = [
         'factories' => [
             'VuFind\AccountCapabilities' => 'VuFind\Service\Factory::getAccountCapabilities',
             'VuFind\AuthManager' => 'VuFind\Auth\Factory::getManager',
-            'VuFind\AuthPluginManager' => 'VuFind\Service\Factory::getAuthPluginManager',
+            'VuFind\Auth\PluginManager' => 'VuFind\ServiceManager\AbstractPluginManagerFactory',
             'VuFind\AutocompletePluginManager' => 'VuFind\Service\Factory::getAutocompletePluginManager',
             'VuFind\Autocomplete\Suggester' => 'VuFind\Autocomplete\SuggesterFactory',
             'VuFind\CacheManager' => 'VuFind\Service\Factory::getCacheManager',
@@ -358,6 +358,7 @@ $config = [
         'aliases' => [
             'mvctranslator' => 'VuFind\Translator',
             'translator' => 'VuFind\Translator',
+            'VuFind\AuthPluginManager' => 'VuFind\Auth\PluginManager',
             'VuFind\ContentPluginManager' => 'VuFind\Content\PluginManager',
             'VuFind\ContentAuthorNotesPluginManager' => 'VuFind\Content\AuthorNotes\PluginManager',
             'VuFind\ContentCoversPluginManager' => 'VuFind\Content\Covers\PluginManager',
diff --git a/module/VuFind/src/VuFind/Auth/Factory.php b/module/VuFind/src/VuFind/Auth/Factory.php
index 72c27463aaa..3b0d9709cc9 100644
--- a/module/VuFind/src/VuFind/Auth/Factory.php
+++ b/module/VuFind/src/VuFind/Auth/Factory.php
@@ -55,7 +55,7 @@ class Factory
             'ChoiceAuth', $sm->get('VuFind\SessionManager')
         );
         $auth = new ChoiceAuth($container);
-        $auth->setPluginManager($sm->get('VuFind\AuthPluginManager'));
+        $auth->setPluginManager($sm->get('VuFind\Auth\PluginManager'));
         return $auth;
     }
 
@@ -147,7 +147,7 @@ class Factory
         // Load remaining dependencies:
         $userTable = $sm->get('VuFind\DbTablePluginManager')->get('user');
         $sessionManager = $sm->get('VuFind\SessionManager');
-        $pm = $sm->get('VuFind\AuthPluginManager');
+        $pm = $sm->get('VuFind\Auth\PluginManager');
         $cookies = $sm->get('VuFind\CookieManager');
 
         // Build the object and make sure account credentials haven't expired:
@@ -166,7 +166,7 @@ class Factory
     public static function getMultiAuth(ServiceManager $sm)
     {
         $auth = new MultiAuth();
-        $auth->setPluginManager($sm->get('VuFind\AuthPluginManager'));
+        $auth->setPluginManager($sm->get('VuFind\Auth\PluginManager'));
         return $auth;
     }
 
diff --git a/module/VuFind/src/VuFind/Service/Factory.php b/module/VuFind/src/VuFind/Service/Factory.php
index a3ad2816ce2..06c6c095bc9 100644
--- a/module/VuFind/src/VuFind/Service/Factory.php
+++ b/module/VuFind/src/VuFind/Service/Factory.php
@@ -57,18 +57,6 @@ class Factory
         );
     }
 
-    /**
-     * Construct the Auth Plugin Manager.
-     *
-     * @param ServiceManager $sm Service manager.
-     *
-     * @return \VuFind\Auth\PluginManager
-     */
-    public static function getAuthPluginManager(ServiceManager $sm)
-    {
-        return static::getGenericPluginManager($sm, 'Auth');
-    }
-
     /**
      * Construct the Autocomplete Plugin Manager.
      *
diff --git a/module/VuFind/src/VuFindTest/Unit/TestCase.php b/module/VuFind/src/VuFindTest/Unit/TestCase.php
index 7f8236cb2f7..1239d204103 100644
--- a/module/VuFind/src/VuFindTest/Unit/TestCase.php
+++ b/module/VuFind/src/VuFindTest/Unit/TestCase.php
@@ -222,11 +222,11 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase
     public function getAuthManager()
     {
         $sm = $this->getServiceManager();
-        if (!$sm->has('VuFind\AuthPluginManager')) {
+        if (!$sm->has('VuFind\Auth\PluginManager')) {
             $authManager = new \VuFind\Auth\PluginManager($sm);
-            $sm->setService('VuFind\AuthPluginManager', $authManager);
+            $sm->setService('VuFind\Auth\PluginManager', $authManager);
         }
-        return $sm->get('VuFind\AuthPluginManager');
+        return $sm->get('VuFind\Auth\PluginManager');
     }
 
     /**
-- 
GitLab